@faststats/web 0.0.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/README.md +4 -0
- package/dist/error.iife.js +3 -0
- package/dist/error.js +3 -0
- package/dist/module.d.ts +502 -0
- package/dist/module.js +403 -0
- package/dist/replay.iife.js +29 -0
- package/dist/replay.js +29 -0
- package/dist/script.iife.js +1 -0
- package/dist/script.js +1 -0
- package/dist/web-vitals.iife.js +1 -0
- package/dist/web-vitals.js +1 -0
- package/package.json +38 -0
- package/src/analytics.ts +544 -0
- package/src/error.ts +324 -0
- package/src/index.ts +95 -0
- package/src/module.ts +6 -0
- package/src/replay.ts +488 -0
- package/src/utils/identifiers.ts +70 -0
- package/src/utils/types.ts +13 -0
- package/src/web-vitals.ts +207 -0
- package/tsconfig.json +30 -0
- package/tsdown.config.ts +51 -0
- package/worker/index.ts +22 -0
- package/wrangler.toml +8 -0
package/dist/module.js
ADDED
|
@@ -0,0 +1,403 @@
|
|
|
1
|
+
//#region src/utils/identifiers.ts
|
|
2
|
+
const SESSION_TIMEOUT = 1800 * 1e3;
|
|
3
|
+
function getAnonymousId(cookieless) {
|
|
4
|
+
if (cookieless) return "";
|
|
5
|
+
return getOrCreateAnonymousId();
|
|
6
|
+
}
|
|
7
|
+
function getOrCreateAnonymousId() {
|
|
8
|
+
if (typeof localStorage === "undefined") return "";
|
|
9
|
+
const existingId = localStorage.getItem("faststats_anon_id");
|
|
10
|
+
if (existingId) return existingId;
|
|
11
|
+
const newId = crypto.randomUUID();
|
|
12
|
+
localStorage.setItem("faststats_anon_id", newId);
|
|
13
|
+
return newId;
|
|
14
|
+
}
|
|
15
|
+
function resetAnonymousId(cookieless) {
|
|
16
|
+
if (cookieless || typeof localStorage === "undefined") return "";
|
|
17
|
+
localStorage.removeItem("faststats_anon_id");
|
|
18
|
+
return getOrCreateAnonymousId();
|
|
19
|
+
}
|
|
20
|
+
function getOrCreateSessionId() {
|
|
21
|
+
if (typeof sessionStorage === "undefined") return "";
|
|
22
|
+
const existingId = sessionStorage.getItem("session_id");
|
|
23
|
+
const sessionTimestamp = sessionStorage.getItem("session_timestamp");
|
|
24
|
+
if (existingId && sessionTimestamp) {
|
|
25
|
+
if (Date.now() - Number.parseInt(sessionTimestamp, 10) < SESSION_TIMEOUT) {
|
|
26
|
+
sessionStorage.setItem("session_timestamp", Date.now().toString());
|
|
27
|
+
return existingId;
|
|
28
|
+
}
|
|
29
|
+
sessionStorage.removeItem("session_id");
|
|
30
|
+
sessionStorage.removeItem("session_timestamp");
|
|
31
|
+
sessionStorage.removeItem("session_start");
|
|
32
|
+
}
|
|
33
|
+
const now = Date.now().toString();
|
|
34
|
+
const newId = crypto.randomUUID();
|
|
35
|
+
sessionStorage.setItem("session_id", newId);
|
|
36
|
+
sessionStorage.setItem("session_timestamp", now);
|
|
37
|
+
sessionStorage.setItem("session_start", now);
|
|
38
|
+
return newId;
|
|
39
|
+
}
|
|
40
|
+
function resetSessionId() {
|
|
41
|
+
if (typeof sessionStorage === "undefined") return "";
|
|
42
|
+
sessionStorage.removeItem("session_id");
|
|
43
|
+
sessionStorage.removeItem("session_timestamp");
|
|
44
|
+
sessionStorage.removeItem("session_start");
|
|
45
|
+
return getOrCreateSessionId();
|
|
46
|
+
}
|
|
47
|
+
function refreshSessionTimestamp() {
|
|
48
|
+
if (typeof sessionStorage === "undefined") return;
|
|
49
|
+
if (sessionStorage.getItem("session_id")) sessionStorage.setItem("session_timestamp", Date.now().toString());
|
|
50
|
+
}
|
|
51
|
+
function getSessionStart() {
|
|
52
|
+
if (typeof sessionStorage === "undefined") return Date.now();
|
|
53
|
+
const start = sessionStorage.getItem("session_start");
|
|
54
|
+
if (start) return Number.parseInt(start, 10);
|
|
55
|
+
const ts = sessionStorage.getItem("session_timestamp");
|
|
56
|
+
return ts ? Number.parseInt(ts, 10) : Date.now();
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
//#endregion
|
|
60
|
+
//#region src/utils/types.ts
|
|
61
|
+
function normalizeSamplingPercentage(value) {
|
|
62
|
+
if (typeof value !== "number" || !Number.isFinite(value)) return 100;
|
|
63
|
+
return Math.max(0, Math.min(100, value));
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
//#endregion
|
|
67
|
+
//#region src/analytics.ts
|
|
68
|
+
function isTrackingDisabled() {
|
|
69
|
+
if (typeof localStorage === "undefined") return false;
|
|
70
|
+
const value = localStorage.getItem("disable-faststats");
|
|
71
|
+
return value === "true" || value === "1";
|
|
72
|
+
}
|
|
73
|
+
async function sendData(options) {
|
|
74
|
+
const { url, data, contentType = "application/json", headers = {}, debug = false, debugPrefix = "[Analytics]" } = options;
|
|
75
|
+
const blob = data instanceof Blob ? data : new Blob([data], { type: contentType });
|
|
76
|
+
if (navigator.sendBeacon?.(url, blob)) {
|
|
77
|
+
if (debug) console.log(`${debugPrefix} ✓ Sent via beacon`);
|
|
78
|
+
return true;
|
|
79
|
+
}
|
|
80
|
+
try {
|
|
81
|
+
const response = await fetch(url, {
|
|
82
|
+
method: "POST",
|
|
83
|
+
body: data,
|
|
84
|
+
headers: {
|
|
85
|
+
"Content-Type": contentType,
|
|
86
|
+
...headers
|
|
87
|
+
},
|
|
88
|
+
keepalive: true
|
|
89
|
+
});
|
|
90
|
+
const success = response.ok;
|
|
91
|
+
if (debug) if (success) console.log(`${debugPrefix} ✓ Sent via fetch`);
|
|
92
|
+
else console.warn(`${debugPrefix} ✗ Failed: ${response.status}`);
|
|
93
|
+
return success;
|
|
94
|
+
} catch {
|
|
95
|
+
if (debug) console.warn(`${debugPrefix} ✗ Failed to send`);
|
|
96
|
+
return false;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
function getLinkEl(el) {
|
|
100
|
+
while (el && !(el.tagName === "A" && el.href)) el = el.parentNode;
|
|
101
|
+
return el;
|
|
102
|
+
}
|
|
103
|
+
function getUTM() {
|
|
104
|
+
const params = {};
|
|
105
|
+
if (!location.search) return params;
|
|
106
|
+
const sp = new URLSearchParams(location.search);
|
|
107
|
+
for (const k of [
|
|
108
|
+
"utm_source",
|
|
109
|
+
"utm_medium",
|
|
110
|
+
"utm_campaign",
|
|
111
|
+
"utm_term",
|
|
112
|
+
"utm_content"
|
|
113
|
+
]) {
|
|
114
|
+
const v = sp.get(k);
|
|
115
|
+
if (v) params[k] = v;
|
|
116
|
+
}
|
|
117
|
+
return params;
|
|
118
|
+
}
|
|
119
|
+
var WebAnalytics = class {
|
|
120
|
+
endpoint;
|
|
121
|
+
debug;
|
|
122
|
+
baseUrl;
|
|
123
|
+
started = false;
|
|
124
|
+
pageKey = "";
|
|
125
|
+
navTimer = null;
|
|
126
|
+
heartbeatTimer = null;
|
|
127
|
+
scrollDepth = 0;
|
|
128
|
+
pageEntryTime = 0;
|
|
129
|
+
pagePath = "";
|
|
130
|
+
pageUrl = "";
|
|
131
|
+
pageHash = "";
|
|
132
|
+
hasLeftCurrentPage = false;
|
|
133
|
+
scrollHandler = null;
|
|
134
|
+
consentMode;
|
|
135
|
+
cookielessWhilePending;
|
|
136
|
+
constructor(options) {
|
|
137
|
+
this.options = options;
|
|
138
|
+
this.endpoint = options.endpoint ?? "https://metrics.faststats.dev/v1/web";
|
|
139
|
+
this.debug = options.debug ?? false;
|
|
140
|
+
this.consentMode = options.consent?.mode ?? "granted";
|
|
141
|
+
this.cookielessWhilePending = options.consent?.cookielessWhilePending ?? true;
|
|
142
|
+
const script = typeof document !== "undefined" ? document.currentScript : null;
|
|
143
|
+
const scriptBase = script?.src ? script.src.substring(0, script.src.lastIndexOf("/")) : "";
|
|
144
|
+
this.baseUrl = (options.baseUrl ?? scriptBase) || (typeof window !== "undefined" ? window.location.origin : "");
|
|
145
|
+
if (options.autoTrack ?? true) this.init();
|
|
146
|
+
}
|
|
147
|
+
log(msg) {
|
|
148
|
+
if (this.debug) console.log(`[Analytics] ${msg}`);
|
|
149
|
+
}
|
|
150
|
+
init() {
|
|
151
|
+
if (typeof window === "undefined") return;
|
|
152
|
+
if (isTrackingDisabled()) {
|
|
153
|
+
this.log("disabled");
|
|
154
|
+
return;
|
|
155
|
+
}
|
|
156
|
+
if ("requestIdleCallback" in window) window.requestIdleCallback(() => this.start());
|
|
157
|
+
else setTimeout(() => this.start(), 1);
|
|
158
|
+
}
|
|
159
|
+
start() {
|
|
160
|
+
if (this.started || typeof window === "undefined") return;
|
|
161
|
+
if (window.__FA_webAnalyticsInstance && window.__FA_webAnalyticsInstance !== this) {
|
|
162
|
+
this.log("already started by another instance");
|
|
163
|
+
return;
|
|
164
|
+
}
|
|
165
|
+
if (isTrackingDisabled()) {
|
|
166
|
+
this.log("disabled");
|
|
167
|
+
return;
|
|
168
|
+
}
|
|
169
|
+
this.started = true;
|
|
170
|
+
window.__FA_webAnalyticsInstance = this;
|
|
171
|
+
window.__FA_getAnonymousId = () => getAnonymousId(this.isCookielessMode());
|
|
172
|
+
window.__FA_getSessionId = getOrCreateSessionId;
|
|
173
|
+
window.__FA_sendData = sendData;
|
|
174
|
+
window.__FA_identify = (externalId, email, options) => this.identify(externalId, email, options);
|
|
175
|
+
window.__FA_logout = (resetAnonymousIdentity) => this.logout(resetAnonymousIdentity);
|
|
176
|
+
window.__FA_setConsentMode = (mode) => this.setConsentMode(mode);
|
|
177
|
+
window.__FA_optIn = () => this.optIn();
|
|
178
|
+
window.__FA_optOut = () => this.optOut();
|
|
179
|
+
window.__FA_isTrackingDisabled = isTrackingDisabled;
|
|
180
|
+
const opts = this.options;
|
|
181
|
+
const hasWebVitalsSampling = opts.webVitals?.sampling?.percentage !== void 0;
|
|
182
|
+
const hasReplaySampling = opts.replayOptions?.samplingPercentage !== void 0 || opts.sessionReplays?.sampling?.percentage !== void 0;
|
|
183
|
+
if (opts.errorTracking?.enabled ?? opts.trackErrors) this.load("error", "__FA_ErrorTracker", {
|
|
184
|
+
siteKey: opts.siteKey,
|
|
185
|
+
endpoint: this.endpoint,
|
|
186
|
+
debug: this.debug,
|
|
187
|
+
getCommonData: () => ({
|
|
188
|
+
url: location.href,
|
|
189
|
+
page: location.pathname,
|
|
190
|
+
referrer: document.referrer || null
|
|
191
|
+
})
|
|
192
|
+
});
|
|
193
|
+
if (opts.webVitals?.enabled ?? opts.trackWebVitals ?? hasWebVitalsSampling) this.load("web-vitals", "__FA_WebVitalsTracker", {
|
|
194
|
+
siteKey: opts.siteKey,
|
|
195
|
+
endpoint: this.endpoint,
|
|
196
|
+
debug: this.debug,
|
|
197
|
+
samplingPercentage: normalizeSamplingPercentage(opts.webVitals?.sampling?.percentage)
|
|
198
|
+
});
|
|
199
|
+
if (opts.sessionReplays?.enabled ?? opts.trackReplay ?? hasReplaySampling) {
|
|
200
|
+
const replayOpts = opts.replayOptions ?? {};
|
|
201
|
+
this.load("replay", "__FA_ReplayTracker", {
|
|
202
|
+
siteKey: opts.siteKey,
|
|
203
|
+
endpoint: this.endpoint,
|
|
204
|
+
debug: this.debug,
|
|
205
|
+
...replayOpts,
|
|
206
|
+
samplingPercentage: normalizeSamplingPercentage(replayOpts.samplingPercentage ?? opts.sessionReplays?.sampling?.percentage)
|
|
207
|
+
});
|
|
208
|
+
}
|
|
209
|
+
this.enterPage();
|
|
210
|
+
this.pageview({ trigger: "load" });
|
|
211
|
+
this.links();
|
|
212
|
+
this.trackScroll();
|
|
213
|
+
this.startHeartbeat();
|
|
214
|
+
document.addEventListener("visibilitychange", () => {
|
|
215
|
+
if (document.visibilityState === "hidden") this.leavePage();
|
|
216
|
+
else this.startHeartbeat();
|
|
217
|
+
});
|
|
218
|
+
window.addEventListener("pagehide", () => this.leavePage());
|
|
219
|
+
window.addEventListener("popstate", () => this.navigate());
|
|
220
|
+
if (opts.trackHash) window.addEventListener("hashchange", () => this.navigate());
|
|
221
|
+
this.patch();
|
|
222
|
+
}
|
|
223
|
+
load(script, key, trackerOpts) {
|
|
224
|
+
const el = document.createElement("script");
|
|
225
|
+
el.src = `${this.baseUrl}/${script}.js`;
|
|
226
|
+
el.async = true;
|
|
227
|
+
el.onload = () => {
|
|
228
|
+
const Ctor = window[key];
|
|
229
|
+
if (Ctor) {
|
|
230
|
+
new Ctor(trackerOpts).start();
|
|
231
|
+
this.log(`${script} loaded`);
|
|
232
|
+
}
|
|
233
|
+
};
|
|
234
|
+
el.onerror = () => {
|
|
235
|
+
if (this.debug) console.warn(`[Analytics] ${script} failed`);
|
|
236
|
+
};
|
|
237
|
+
document.head.appendChild(el);
|
|
238
|
+
}
|
|
239
|
+
pageview(extra = {}) {
|
|
240
|
+
const key = `${location.pathname}|${this.options.trackHash ?? false ? location.hash : ""}`;
|
|
241
|
+
if (key === this.pageKey) return;
|
|
242
|
+
this.pageKey = key;
|
|
243
|
+
this.send("pageview", extra);
|
|
244
|
+
}
|
|
245
|
+
track(name, extra = {}) {
|
|
246
|
+
this.send(name, extra);
|
|
247
|
+
}
|
|
248
|
+
identify(externalId, email, options = {}) {
|
|
249
|
+
if (isTrackingDisabled()) return;
|
|
250
|
+
if (this.isCookielessMode()) return;
|
|
251
|
+
const trimmedExternalId = externalId.trim();
|
|
252
|
+
const trimmedEmail = email.trim();
|
|
253
|
+
if (!trimmedExternalId || !trimmedEmail) return;
|
|
254
|
+
sendData({
|
|
255
|
+
url: this.endpoint.replace(/\/v1\/web$/, "/v1/identify"),
|
|
256
|
+
data: JSON.stringify({
|
|
257
|
+
token: this.options.siteKey,
|
|
258
|
+
identifier: getAnonymousId(false),
|
|
259
|
+
externalId: trimmedExternalId,
|
|
260
|
+
email: trimmedEmail,
|
|
261
|
+
name: options.name?.trim() || void 0,
|
|
262
|
+
phone: options.phone?.trim() || void 0,
|
|
263
|
+
avatarUrl: options.avatarUrl?.trim() || void 0,
|
|
264
|
+
traits: options.traits ?? {}
|
|
265
|
+
}),
|
|
266
|
+
contentType: "text/plain",
|
|
267
|
+
debug: this.debug,
|
|
268
|
+
debugPrefix: "[Analytics] identify"
|
|
269
|
+
});
|
|
270
|
+
}
|
|
271
|
+
logout(resetAnonymousIdentity = true) {
|
|
272
|
+
if (isTrackingDisabled()) return;
|
|
273
|
+
if (resetAnonymousIdentity) resetAnonymousId(this.isCookielessMode());
|
|
274
|
+
resetSessionId();
|
|
275
|
+
}
|
|
276
|
+
setConsentMode(mode) {
|
|
277
|
+
this.consentMode = mode;
|
|
278
|
+
}
|
|
279
|
+
optIn() {
|
|
280
|
+
this.setConsentMode("granted");
|
|
281
|
+
}
|
|
282
|
+
optOut() {
|
|
283
|
+
this.setConsentMode("denied");
|
|
284
|
+
}
|
|
285
|
+
getConsentMode() {
|
|
286
|
+
return this.consentMode;
|
|
287
|
+
}
|
|
288
|
+
isCookielessMode() {
|
|
289
|
+
if (this.options.cookieless) return true;
|
|
290
|
+
if (this.consentMode === "denied") return true;
|
|
291
|
+
if (this.consentMode === "pending") return this.cookielessWhilePending;
|
|
292
|
+
return false;
|
|
293
|
+
}
|
|
294
|
+
send(event, extra = {}) {
|
|
295
|
+
const identifier = getAnonymousId(this.isCookielessMode());
|
|
296
|
+
const payload = JSON.stringify({
|
|
297
|
+
token: this.options.siteKey,
|
|
298
|
+
...identifier ? { userId: identifier } : {},
|
|
299
|
+
sessionId: getOrCreateSessionId(),
|
|
300
|
+
data: {
|
|
301
|
+
event,
|
|
302
|
+
page: location.pathname,
|
|
303
|
+
referrer: document.referrer || null,
|
|
304
|
+
title: document.title || "",
|
|
305
|
+
url: location.href,
|
|
306
|
+
...getUTM(),
|
|
307
|
+
...extra
|
|
308
|
+
}
|
|
309
|
+
});
|
|
310
|
+
this.log(event);
|
|
311
|
+
sendData({
|
|
312
|
+
url: this.endpoint,
|
|
313
|
+
data: payload,
|
|
314
|
+
contentType: "text/plain",
|
|
315
|
+
debug: this.debug,
|
|
316
|
+
debugPrefix: `[Analytics] ${event}`
|
|
317
|
+
});
|
|
318
|
+
}
|
|
319
|
+
enterPage() {
|
|
320
|
+
this.pageEntryTime = Date.now();
|
|
321
|
+
this.pagePath = location.pathname;
|
|
322
|
+
this.pageUrl = location.href;
|
|
323
|
+
this.pageHash = location.hash;
|
|
324
|
+
this.scrollDepth = 0;
|
|
325
|
+
this.hasLeftCurrentPage = false;
|
|
326
|
+
}
|
|
327
|
+
leavePage() {
|
|
328
|
+
if (this.hasLeftCurrentPage) return;
|
|
329
|
+
this.hasLeftCurrentPage = true;
|
|
330
|
+
const now = Date.now();
|
|
331
|
+
this.send("page_leave", {
|
|
332
|
+
page: this.pagePath,
|
|
333
|
+
url: this.pageUrl,
|
|
334
|
+
time_on_page: now - this.pageEntryTime,
|
|
335
|
+
scroll_depth: this.scrollDepth,
|
|
336
|
+
session_duration: now - getSessionStart()
|
|
337
|
+
});
|
|
338
|
+
}
|
|
339
|
+
trackScroll() {
|
|
340
|
+
if (this.scrollHandler) window.removeEventListener("scroll", this.scrollHandler);
|
|
341
|
+
const update = () => {
|
|
342
|
+
const doc = document.documentElement;
|
|
343
|
+
const body = document.body;
|
|
344
|
+
const viewportH = window.innerHeight;
|
|
345
|
+
const docH = Math.max(doc.scrollHeight, body.scrollHeight);
|
|
346
|
+
if (docH <= viewportH) {
|
|
347
|
+
this.scrollDepth = 100;
|
|
348
|
+
return;
|
|
349
|
+
}
|
|
350
|
+
const depth = Math.min(100, Math.round(((window.scrollY || doc.scrollTop) + viewportH) / docH * 100));
|
|
351
|
+
if (depth > this.scrollDepth) this.scrollDepth = depth;
|
|
352
|
+
};
|
|
353
|
+
this.scrollHandler = update;
|
|
354
|
+
update();
|
|
355
|
+
window.addEventListener("scroll", update, { passive: true });
|
|
356
|
+
}
|
|
357
|
+
startHeartbeat() {
|
|
358
|
+
if (this.heartbeatTimer) clearInterval(this.heartbeatTimer);
|
|
359
|
+
this.heartbeatTimer = setInterval(() => {
|
|
360
|
+
if (document.visibilityState === "hidden") {
|
|
361
|
+
clearInterval(this.heartbeatTimer);
|
|
362
|
+
this.heartbeatTimer = null;
|
|
363
|
+
return;
|
|
364
|
+
}
|
|
365
|
+
refreshSessionTimestamp();
|
|
366
|
+
}, 300 * 1e3);
|
|
367
|
+
}
|
|
368
|
+
navigate() {
|
|
369
|
+
if (this.navTimer) clearTimeout(this.navTimer);
|
|
370
|
+
this.navTimer = setTimeout(() => {
|
|
371
|
+
this.navTimer = null;
|
|
372
|
+
const pathChanged = location.pathname !== this.pagePath;
|
|
373
|
+
const hashChanged = (this.options.trackHash ?? false) && location.hash !== this.pageHash;
|
|
374
|
+
if (!pathChanged && !hashChanged) return;
|
|
375
|
+
this.leavePage();
|
|
376
|
+
this.enterPage();
|
|
377
|
+
this.trackScroll();
|
|
378
|
+
this.pageview({ trigger: "navigation" });
|
|
379
|
+
}, 300);
|
|
380
|
+
}
|
|
381
|
+
patch() {
|
|
382
|
+
const fire = () => this.navigate();
|
|
383
|
+
for (const method of ["pushState", "replaceState"]) {
|
|
384
|
+
const orig = history[method];
|
|
385
|
+
history[method] = function(...args) {
|
|
386
|
+
const result = orig.apply(this, args);
|
|
387
|
+
fire();
|
|
388
|
+
return result;
|
|
389
|
+
};
|
|
390
|
+
}
|
|
391
|
+
}
|
|
392
|
+
links() {
|
|
393
|
+
const handler = (event) => {
|
|
394
|
+
const link = getLinkEl(event.target);
|
|
395
|
+
if (link && link.host !== location.host) this.track("outbound_link", { outbound_link: link.href });
|
|
396
|
+
};
|
|
397
|
+
document.addEventListener("click", handler);
|
|
398
|
+
document.addEventListener("auxclick", handler);
|
|
399
|
+
}
|
|
400
|
+
};
|
|
401
|
+
|
|
402
|
+
//#endregion
|
|
403
|
+
export { WebAnalytics };
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
var FA_Replay=(function(){var e=Object.defineProperty,t=(t,n,r)=>n in t?e(t,n,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[n]=r,n=(e,n,r)=>t(e,typeof n==`symbol`?n:n+``,r);function r(e,t,n){try{if(!(t in e))return()=>{};let r=e[t],i=n(r);return typeof i==`function`&&(i.prototype=i.prototype||{},Object.defineProperties(i,{__rrweb_original__:{enumerable:!1,value:r}})),e[t]=i,()=>{e[t]=r}}catch{return()=>{}}}var i=class{constructor(e){n(this,`fileName`),n(this,`functionName`),n(this,`lineNumber`),n(this,`columnNumber`),this.fileName=e.fileName||``,this.functionName=e.functionName||``,this.lineNumber=e.lineNumber,this.columnNumber=e.columnNumber}toString(){let e=this.lineNumber||``,t=this.columnNumber||``;return this.functionName?`${this.functionName} (${this.fileName}:${e}:${t})`:`${this.fileName}:${e}:${t}`}};let a=/(^|@)\S+:\d+/,o=/^\s*at .*(\S+:\d+|\(native\))/m,s=/^(eval@)?(\[native code])?$/,c={parse:function(e){return e?e.stacktrace!==void 0||e[`opera#sourceloc`]!==void 0?this.parseOpera(e):e.stack&&e.stack.match(o)?this.parseV8OrIE(e):e.stack?this.parseFFOrSafari(e):(console.warn(`[console-record-plugin]: Failed to parse error object:`,e),[]):[]},extractLocation:function(e){if(e.indexOf(`:`)===-1)return[e];let t=/(.+?)(?::(\d+))?(?::(\d+))?$/.exec(e.replace(/[()]/g,``));if(!t)throw Error(`Cannot parse given url: ${e}`);return[t[1],t[2]||void 0,t[3]||void 0]},parseV8OrIE:function(e){return e.stack.split(`
|
|
2
|
+
`).filter(function(e){return!!e.match(o)},this).map(function(e){e.indexOf(`(eval `)>-1&&(e=e.replace(/eval code/g,`eval`).replace(/(\(eval at [^()]*)|(\),.*$)/g,``));let t=e.replace(/^\s+/,``).replace(/\(eval code/g,`(`),n=t.match(/ (\((.+):(\d+):(\d+)\)$)/);t=n?t.replace(n[0],``):t;let r=t.split(/\s+/).slice(1),a=this.extractLocation(n?n[1]:r.pop());return new i({functionName:r.join(` `)||void 0,fileName:[`eval`,`<anonymous>`].indexOf(a[0])>-1?void 0:a[0],lineNumber:a[1],columnNumber:a[2]})},this)},parseFFOrSafari:function(e){return e.stack.split(`
|
|
3
|
+
`).filter(function(e){return!e.match(s)},this).map(function(e){if(e.indexOf(` > eval`)>-1&&(e=e.replace(/ line (\d+)(?: > eval line \d+)* > eval:\d+:\d+/g,`:$1`)),e.indexOf(`@`)===-1&&e.indexOf(`:`)===-1)return new i({functionName:e});{let t=/((.*".+"[^@]*)?[^@]*)(?:@)/,n=e.match(t),r=n&&n[1]?n[1]:void 0,a=this.extractLocation(e.replace(t,``));return new i({functionName:r,fileName:a[0],lineNumber:a[1],columnNumber:a[2]})}},this)},parseOpera:function(e){return!e.stacktrace||e.message.indexOf(`
|
|
4
|
+
`)>-1&&e.message.split(`
|
|
5
|
+
`).length>e.stacktrace.split(`
|
|
6
|
+
`).length?this.parseOpera9(e):e.stack?this.parseOpera11(e):this.parseOpera10(e)},parseOpera9:function(e){let t=/Line (\d+).*script (?:in )?(\S+)/i,n=e.message.split(`
|
|
7
|
+
`),r=[];for(let e=2,a=n.length;e<a;e+=2){let a=t.exec(n[e]);a&&r.push(new i({fileName:a[2],lineNumber:parseFloat(a[1])}))}return r},parseOpera10:function(e){let t=/Line (\d+).*script (?:in )?(\S+)(?:: In function (\S+))?$/i,n=e.stacktrace.split(`
|
|
8
|
+
`),r=[];for(let e=0,a=n.length;e<a;e+=2){let a=t.exec(n[e]);a&&r.push(new i({functionName:a[3]||void 0,fileName:a[2],lineNumber:parseFloat(a[1])}))}return r},parseOpera11:function(e){return e.stack.split(`
|
|
9
|
+
`).filter(function(e){return!!e.match(a)&&!e.match(/^Error created at/)},this).map(function(e){let t=e.split(`@`),n=this.extractLocation(t.pop());return new i({functionName:(t.shift()||``).replace(/<anonymous function(: (\w+))?>/,`$2`).replace(/\([^)]*\)/g,``)||void 0,fileName:n[0],lineNumber:n[1],columnNumber:n[2]})},this)}};function l(e){if(!e||!e.outerHTML)return``;let t=``;for(;e.parentElement;){let n=e.localName;if(!n)break;n=n.toLowerCase();let r=e.parentElement,i=[];if(r.children&&r.children.length>0)for(let e=0;e<r.children.length;e++){let t=r.children[e];t.localName&&t.localName.toLowerCase&&t.localName.toLowerCase()===n&&i.push(t)}i.length>1&&(n+=`:eq(${i.indexOf(e)})`),t=n+(t?`>`+t:``),e=r}return t}function u(e){return Object.prototype.toString.call(e)===`[object Object]`}function d(e,t){if(t===0)return!0;let n=Object.keys(e);for(let r of n)if(u(e[r])&&d(e[r],t-1))return!0;return!1}function f(e,t){let n={numOfKeysLimit:50,depthOfLimit:4};Object.assign(n,t);let r=[],i=[];return JSON.stringify(e,function(e,t){if(r.length>0){let n=r.indexOf(this);~n?r.splice(n+1):r.push(this),~n?i.splice(n,1/0,e):i.push(e),~r.indexOf(t)&&(t=r[0]===t?`[Circular ~]`:`[Circular ~.`+i.slice(0,r.indexOf(t)).join(`.`)+`]`)}else r.push(t);if(t===null)return t;if(t===void 0)return`undefined`;if(a(t))return o(t);if(typeof t==`bigint`)return t.toString()+`n`;if(t instanceof Event){let e={};for(let n in t){let r=t[n];Array.isArray(r)?e[n]=l(r.length?r[0]:null):e[n]=r}return e}else if(t instanceof Node)return t instanceof HTMLElement?t?t.outerHTML:``:t.nodeName;else if(t instanceof Error)return t.stack?t.stack+`
|
|
10
|
+
End of stack for Error object`:t.name+`: `+t.message;return t});function a(e){return!!(u(e)&&Object.keys(e).length>n.numOfKeysLimit||typeof e==`function`||u(e)&&d(e,n.depthOfLimit))}function o(e){let t=e.toString();return n.stringLengthLimit&&t.length>n.stringLengthLimit&&(t=`${t.slice(0,n.stringLengthLimit)}...`),t}}let p={level:[`assert`,`clear`,`count`,`countReset`,`debug`,`dir`,`dirxml`,`error`,`group`,`groupCollapsed`,`groupEnd`,`info`,`log`,`table`,`time`,`timeEnd`,`timeLog`,`trace`,`warn`],lengthThreshold:1e3,logger:`console`};function m(e,t,n){let i=n?Object.assign({},p,n):p,a=i.logger;if(!a)return()=>{};let o;o=typeof a==`string`?t[a]:a;let s=0,l=!1,u=[];if(i.level.includes(`error`)){let n=t=>{let n=t.message,r=t.error;e({level:`error`,trace:c.parse(r).map(e=>e.toString()),payload:[f(n,i.stringifyOptions)]})};t.addEventListener(`error`,n),u.push(()=>{t.removeEventListener(`error`,n)});let r=t=>{let n,r;t.reason instanceof Error?(n=t.reason,r=[f(`Uncaught (in promise) ${n.name}: ${n.message}`,i.stringifyOptions)]):(n=Error(),r=[f(`Uncaught (in promise)`,i.stringifyOptions),f(t.reason,i.stringifyOptions)]),e({level:`error`,trace:c.parse(n).map(e=>e.toString()),payload:r})};t.addEventListener(`unhandledrejection`,r),u.push(()=>{t.removeEventListener(`unhandledrejection`,r)})}for(let e of i.level)u.push(d(o,e));return()=>{u.forEach(e=>e())};function d(t,n){return t[n]?r(t,n,t=>(...r)=>{if(t.apply(this,r),!(n===`assert`&&r[0])&&!l){l=!0;try{let t=c.parse(Error()).map(e=>e.toString()).splice(1),a=(n===`assert`?r.slice(1):r).map(e=>f(e,i.stringifyOptions));s++,s<i.lengthThreshold?e({level:n,trace:t,payload:a}):s===i.lengthThreshold&&e({level:`warn`,trace:[],payload:[f(`The number of log records reached the threshold.`)]})}catch(e){t(`rrweb logger error:`,e,...r)}finally{l=!1}}}):()=>{}}}let h=e=>({name:`rrweb/console@1`,observer:m,options:e});var g;(function(e){e[e.Document=0]=`Document`,e[e.DocumentType=1]=`DocumentType`,e[e.Element=2]=`Element`,e[e.Text=3]=`Text`,e[e.CDATA=4]=`CDATA`,e[e.Comment=5]=`Comment`})(g||={});function _(e){return e.nodeType===e.ELEMENT_NODE}function v(e){return e?.host?.shadowRoot===e}function y(e){return Object.prototype.toString.call(e)===`[object ShadowRoot]`}function b(e){return e.includes(` background-clip: text;`)&&!e.includes(` -webkit-background-clip: text;`)&&(e=e.replace(` background-clip: text;`,` -webkit-background-clip: text; background-clip: text;`)),e}function x(e){try{var t=e.rules||e.cssRules;return t?b(Array.from(t).map(S).join(``)):null}catch{return null}}function S(e){var t=e.cssText;if(C(e))try{t=x(e.styleSheet)||t}catch{}return t}function C(e){return`styleSheet`in e}var w=function(){function e(){this.idNodeMap=new Map,this.nodeMetaMap=new WeakMap}return e.prototype.getId=function(e){return e?this.getMeta(e)?.id??-1:-1},e.prototype.getNode=function(e){return this.idNodeMap.get(e)||null},e.prototype.getIds=function(){return Array.from(this.idNodeMap.keys())},e.prototype.getMeta=function(e){return this.nodeMetaMap.get(e)||null},e.prototype.removeNodeFromMap=function(e){var t=this,n=this.getId(e);this.idNodeMap.delete(n),e.childNodes&&e.childNodes.forEach(function(e){return t.removeNodeFromMap(e)})},e.prototype.has=function(e){return this.idNodeMap.has(e)},e.prototype.hasNode=function(e){return this.nodeMetaMap.has(e)},e.prototype.add=function(e,t){var n=t.id;this.idNodeMap.set(n,e),this.nodeMetaMap.set(e,t)},e.prototype.replace=function(e,t){var n=this.getNode(e);if(n){var r=this.nodeMetaMap.get(n);r&&this.nodeMetaMap.set(t,r)}this.idNodeMap.set(e,t)},e.prototype.reset=function(){this.idNodeMap=new Map,this.nodeMetaMap=new WeakMap},e}();function T(){return new w}function E(e){var t=e.maskInputOptions,n=e.tagName,r=e.type,i=e.value,a=e.maskInputFn,o=i||``;return(t[n.toLowerCase()]||t[r])&&(o=a?a(o):`*`.repeat(o.length)),o}var D=`__rrweb_original__`;function O(e){var t=e.getContext(`2d`);if(!t)return!0;for(var n=50,r=0;r<e.width;r+=n)for(var i=0;i<e.height;i+=n){var a=t.getImageData,o=D in a?a[D]:a;if(new Uint32Array(o.call(t,r,i,Math.min(n,e.width-r),Math.min(n,e.height-i)).data.buffer).some(function(e){return e!==0}))return!1}return!0}var k=1,A=RegExp(`[^a-z0-9-_:]`),j=-2;function M(){return k++}function N(e){if(e instanceof HTMLFormElement)return`form`;var t=e.tagName.toLowerCase().trim();return A.test(t)?`div`:t}function P(e){return e.cssRules?Array.from(e.cssRules).map(function(e){return e.cssText||``}).join(``):``}function F(e){var t=``;return t=e.indexOf(`//`)>-1?e.split(`/`).slice(0,3).join(`/`):e.split(`/`)[0],t=t.split(`?`)[0],t}var I,L,R=/url\((?:(')([^']*)'|(")(.*?)"|([^)]*))\)/gm,z=/^(?!www\.|(?:http|ftp)s?:\/\/|[A-Za-z]:\\|\/\/|#).*/,B=/^(data:)([^,]*),(.*)/i;function V(e,t){return(e||``).replace(R,function(e,n,r,i,a,o){var s=r||a||o,c=n||i||``;if(!s)return e;if(!z.test(s)||B.test(s))return`url(${c}${s}${c})`;if(s[0]===`/`)return`url(${c}${F(t)+s}${c})`;var l=t.split(`/`),u=s.split(`/`);l.pop();for(var d=0,f=u;d<f.length;d++){var p=f[d];p!==`.`&&(p===`..`?l.pop():l.push(p))}return`url(${c}${l.join(`/`)}${c})`})}var H=/^[^ \t\n\r\u000c]+/,ee=/^[, \t\n\r\u000c]+/;function U(e,t){if(t.trim()===``)return t;var n=0;function r(e){var r,i=e.exec(t.substring(n));return i?(r=i[0],n+=r.length,r):``}for(var i=[];r(ee),!(n>=t.length);){var a=r(H);if(a.slice(-1)===`,`)a=te(e,a.substring(0,a.length-1)),i.push(a);else{var o=``;a=te(e,a);for(var s=!1;;){var c=t.charAt(n);if(c===``){i.push((a+o).trim());break}else if(s)c===`)`&&(s=!1);else if(c===`,`){n+=1,i.push((a+o).trim());break}else c===`(`&&(s=!0);o+=c,n+=1}}}return i.join(`, `)}function te(e,t){if(!t||t.trim()===``)return t;var n=e.createElement(`a`);return n.href=t,n.href}function ne(e){return!!(e.tagName===`svg`||e.ownerSVGElement)}function re(){var e=document.createElement(`a`);return e.href=``,e.href}function ie(e,t,n,r){return n===`src`||n===`href`&&r&&!(t===`use`&&r[0]===`#`)||n===`xlink:href`&&r&&r[0]!==`#`||n===`background`&&r&&(t===`table`||t===`td`||t===`th`)?te(e,r):n===`srcset`&&r?U(e,r):n===`style`&&r?V(r,re()):t===`object`&&n===`data`&&r?te(e,r):r}function ae(e,t,n){if(typeof t==`string`){if(e.classList.contains(t))return!0}else for(var r=e.classList.length;r--;){var i=e.classList[r];if(t.test(i))return!0}return n?e.matches(n):!1}function oe(e,t,n){if(!e)return!1;if(e.nodeType!==e.ELEMENT_NODE)return n?oe(e.parentNode,t,n):!1;for(var r=e.classList.length;r--;){var i=e.classList[r];if(t.test(i))return!0}return n?oe(e.parentNode,t,n):!1}function W(e,t,n){var r=e.nodeType===e.ELEMENT_NODE?e:e.parentElement;if(r===null)return!1;if(typeof t==`string`){if(r.classList.contains(t)||r.closest(`.${t}`))return!0}else if(oe(r,t,!0))return!0;return!!(n&&(r.matches(n)||r.closest(n)))}function se(e,t,n){var r=e.contentWindow;if(r){var i=!1,a;try{a=r.document.readyState}catch{return}if(a!==`complete`){var o=setTimeout(function(){i||=(t(),!0)},n);e.addEventListener(`load`,function(){clearTimeout(o),i=!0,t()});return}var s=`about:blank`;if(r.location.href!==s||e.src===s||e.src===``)return setTimeout(t,0),e.addEventListener(`load`,t);e.addEventListener(`load`,t)}}function ce(e,t,n){var r=!1,i;try{i=e.sheet}catch{return}if(!i){var a=setTimeout(function(){r||=(t(),!0)},n);e.addEventListener(`load`,function(){clearTimeout(a),r=!0,t()})}}function le(e,t){var n=t.doc,r=t.mirror,i=t.blockClass,a=t.blockSelector,o=t.maskTextClass,s=t.maskTextSelector,c=t.inlineStylesheet,l=t.maskInputOptions,u=l===void 0?{}:l,d=t.maskTextFn,f=t.maskInputFn,p=t.dataURLOptions,m=p===void 0?{}:p,h=t.inlineImages,_=t.recordCanvas,v=t.keepIframeSrcFn,y=t.newlyAddedElement,b=y===void 0?!1:y,x=ue(n,r);switch(e.nodeType){case e.DOCUMENT_NODE:return e.compatMode===`CSS1Compat`?{type:g.Document,childNodes:[]}:{type:g.Document,childNodes:[],compatMode:e.compatMode};case e.DOCUMENT_TYPE_NODE:return{type:g.DocumentType,name:e.name,publicId:e.publicId,systemId:e.systemId,rootId:x};case e.ELEMENT_NODE:return fe(e,{doc:n,blockClass:i,blockSelector:a,inlineStylesheet:c,maskInputOptions:u,maskInputFn:f,dataURLOptions:m,inlineImages:h,recordCanvas:_,keepIframeSrcFn:v,newlyAddedElement:b,rootId:x});case e.TEXT_NODE:return de(e,{maskTextClass:o,maskTextSelector:s,maskTextFn:d,rootId:x});case e.CDATA_SECTION_NODE:return{type:g.CDATA,textContent:``,rootId:x};case e.COMMENT_NODE:return{type:g.Comment,textContent:e.textContent||``,rootId:x};default:return!1}}function ue(e,t){if(t.hasNode(e)){var n=t.getId(e);return n===1?void 0:n}}function de(e,t){var n=t.maskTextClass,r=t.maskTextSelector,i=t.maskTextFn,a=t.rootId,o=e.parentNode&&e.parentNode.tagName,s=e.textContent,c=o===`STYLE`?!0:void 0,l=o===`SCRIPT`?!0:void 0;if(c&&s){try{e.nextSibling||e.previousSibling||e.parentNode.sheet?.cssRules&&(s=P(e.parentNode.sheet))}catch(t){console.warn(`Cannot get CSS styles from text's parentNode. Error: ${t}`,e)}s=V(s,re())}return l&&(s=`SCRIPT_PLACEHOLDER`),!c&&!l&&s&&W(e,n,r)&&(s=i?i(s):s.replace(/[\S]/g,`*`)),{type:g.Text,textContent:s||``,isStyle:c,rootId:a}}function fe(e,t){for(var n=t.doc,r=t.blockClass,i=t.blockSelector,a=t.inlineStylesheet,o=t.maskInputOptions,s=o===void 0?{}:o,c=t.maskInputFn,l=t.dataURLOptions,u=l===void 0?{}:l,d=t.inlineImages,f=t.recordCanvas,p=t.keepIframeSrcFn,m=t.newlyAddedElement,h=m===void 0?!1:m,_=t.rootId,v=ae(e,r,i),y=N(e),b={},S=e.attributes.length,C=0;C<S;C++){var w=e.attributes[C];b[w.name]=ie(n,y,w.name,w.value)}if(y===`link`&&a){var T=Array.from(n.styleSheets).find(function(t){return t.href===e.href}),D=null;T&&(D=x(T)),D&&(delete b.rel,delete b.href,b._cssText=V(D,T.href))}if(y===`style`&&e.sheet&&!(e.innerText||e.textContent||``).trim().length){var D=x(e.sheet);D&&(b._cssText=V(D,re()))}if(y===`input`||y===`textarea`||y===`select`){var k=e.value,A=e.checked;b.type!==`radio`&&b.type!==`checkbox`&&b.type!==`submit`&&b.type!==`button`&&k?b.value=E({type:b.type,tagName:y,value:k,maskInputOptions:s,maskInputFn:c}):A&&(b.checked=A)}if(y===`option`&&(e.selected&&!s.select?b.selected=!0:delete b.selected),y===`canvas`&&f){if(e.__context===`2d`)O(e)||(b.rr_dataURL=e.toDataURL(u.type,u.quality));else if(!(`__context`in e)){var j=e.toDataURL(u.type,u.quality),M=document.createElement(`canvas`);M.width=e.width,M.height=e.height,j!==M.toDataURL(u.type,u.quality)&&(b.rr_dataURL=j)}}if(y===`img`&&d){I||(I=n.createElement(`canvas`),L=I.getContext(`2d`));var P=e,F=P.crossOrigin;P.crossOrigin=`anonymous`;var R=function(){try{I.width=P.naturalWidth,I.height=P.naturalHeight,L.drawImage(P,0,0),b.rr_dataURL=I.toDataURL(u.type,u.quality)}catch(e){console.warn(`Cannot inline img src=${P.currentSrc}! Error: ${e}`)}F?b.crossOrigin=F:P.removeAttribute(`crossorigin`)};P.complete&&P.naturalWidth!==0?R():P.onload=R}if((y===`audio`||y===`video`)&&(b.rr_mediaState=e.paused?`paused`:`played`,b.rr_mediaCurrentTime=e.currentTime),h||(e.scrollLeft&&(b.rr_scrollLeft=e.scrollLeft),e.scrollTop&&(b.rr_scrollTop=e.scrollTop)),v){var z=e.getBoundingClientRect(),B=z.width,H=z.height;b={class:b.class,rr_width:`${B}px`,rr_height:`${H}px`}}return y===`iframe`&&!p(b.src)&&(e.contentDocument||(b.rr_src=b.src),delete b.src),{type:g.Element,tagName:y,attributes:b,childNodes:[],isSVG:ne(e)||void 0,needBlock:v,rootId:_}}function G(e){return e===void 0?``:e.toLowerCase()}function pe(e,t){return!!(t.comment&&e.type===g.Comment||e.type===g.Element&&(t.script&&(e.tagName===`script`||e.tagName===`link`&&e.attributes.rel===`preload`&&e.attributes.as===`script`||e.tagName===`link`&&e.attributes.rel===`prefetch`&&typeof e.attributes.href==`string`&&e.attributes.href.endsWith(`.js`))||t.headFavicon&&(e.tagName===`link`&&e.attributes.rel===`shortcut icon`||e.tagName===`meta`&&(G(e.attributes.name).match(/^msapplication-tile(image|color)$/)||G(e.attributes.name)===`application-name`||G(e.attributes.rel)===`icon`||G(e.attributes.rel)===`apple-touch-icon`||G(e.attributes.rel)===`shortcut icon`))||e.tagName===`meta`&&(t.headMetaDescKeywords&&G(e.attributes.name).match(/^description|keywords$/)||t.headMetaSocial&&(G(e.attributes.property).match(/^(og|twitter|fb):/)||G(e.attributes.name).match(/^(og|twitter):/)||G(e.attributes.name)===`pinterest`)||t.headMetaRobots&&(G(e.attributes.name)===`robots`||G(e.attributes.name)===`googlebot`||G(e.attributes.name)===`bingbot`)||t.headMetaHttpEquiv&&e.attributes[`http-equiv`]!==void 0||t.headMetaAuthorship&&(G(e.attributes.name)===`author`||G(e.attributes.name)===`generator`||G(e.attributes.name)===`framework`||G(e.attributes.name)===`publisher`||G(e.attributes.name)===`progid`||G(e.attributes.property).match(/^article:/)||G(e.attributes.property).match(/^product:/))||t.headMetaVerification&&(G(e.attributes.name)===`google-site-verification`||G(e.attributes.name)===`yandex-verification`||G(e.attributes.name)===`csrf-token`||G(e.attributes.name)===`p:domain_verify`||G(e.attributes.name)===`verify-v1`||G(e.attributes.name)===`verification`||G(e.attributes.name)===`shopify-checkout-api-token`))))}function me(e,t){var n=t.doc,r=t.mirror,i=t.blockClass,a=t.blockSelector,o=t.maskTextClass,s=t.maskTextSelector,c=t.skipChild,l=c===void 0?!1:c,u=t.inlineStylesheet,d=u===void 0?!0:u,f=t.maskInputOptions,p=f===void 0?{}:f,m=t.maskTextFn,h=t.maskInputFn,b=t.slimDOMOptions,x=t.dataURLOptions,S=x===void 0?{}:x,C=t.inlineImages,w=C===void 0?!1:C,T=t.recordCanvas,E=T===void 0?!1:T,D=t.onSerialize,O=t.onIframeLoad,k=t.iframeLoadTimeout,A=k===void 0?5e3:k,N=t.onStylesheetLoad,P=t.stylesheetLoadTimeout,F=P===void 0?5e3:P,I=t.keepIframeSrcFn,L=I===void 0?function(){return!1}:I,R=t.newlyAddedElement,z=R===void 0?!1:R,B=t.preserveWhiteSpace,V=B===void 0?!0:B,H=le(e,{doc:n,mirror:r,blockClass:i,blockSelector:a,maskTextClass:o,maskTextSelector:s,inlineStylesheet:d,maskInputOptions:p,maskTextFn:m,maskInputFn:h,dataURLOptions:S,inlineImages:w,recordCanvas:E,keepIframeSrcFn:L,newlyAddedElement:z});if(!H)return console.warn(e,`not serialized`),null;var ee=r.hasNode(e)?r.getId(e):pe(H,b)||!V&&H.type===g.Text&&!H.isStyle&&!H.textContent.replace(/^\s+|\s+$/gm,``).length?j:M(),U=Object.assign(H,{id:ee});if(r.add(e,U),ee===j)return null;D&&D(e);var te=!l;if(U.type===g.Element){te&&=!U.needBlock,delete U.needBlock;var ne=e.shadowRoot;ne&&y(ne)&&(U.isShadowHost=!0)}if((U.type===g.Document||U.type===g.Element)&&te){b.headWhitespace&&U.type===g.Element&&U.tagName===`head`&&(V=!1);for(var re={doc:n,mirror:r,blockClass:i,blockSelector:a,maskTextClass:o,maskTextSelector:s,skipChild:l,inlineStylesheet:d,maskInputOptions:p,maskTextFn:m,maskInputFn:h,slimDOMOptions:b,dataURLOptions:S,inlineImages:w,recordCanvas:E,preserveWhiteSpace:V,onSerialize:D,onIframeLoad:O,iframeLoadTimeout:A,onStylesheetLoad:N,stylesheetLoadTimeout:F,keepIframeSrcFn:L},ie=0,ae=Array.from(e.childNodes);ie<ae.length;ie++){var oe=ae[ie],W=me(oe,re);W&&U.childNodes.push(W)}if(_(e)&&e.shadowRoot)for(var ue=0,de=Array.from(e.shadowRoot.childNodes);ue<de.length;ue++){var oe=de[ue],W=me(oe,re);W&&(y(e.shadowRoot)&&(W.isShadow=!0),U.childNodes.push(W))}}return e.parentNode&&v(e.parentNode)&&y(e.parentNode)&&(U.isShadow=!0),U.type===g.Element&&U.tagName===`iframe`&&se(e,function(){var t=e.contentDocument;if(t&&O){var n=me(t,{doc:t,mirror:r,blockClass:i,blockSelector:a,maskTextClass:o,maskTextSelector:s,skipChild:!1,inlineStylesheet:d,maskInputOptions:p,maskTextFn:m,maskInputFn:h,slimDOMOptions:b,dataURLOptions:S,inlineImages:w,recordCanvas:E,preserveWhiteSpace:V,onSerialize:D,onIframeLoad:O,iframeLoadTimeout:A,onStylesheetLoad:N,stylesheetLoadTimeout:F,keepIframeSrcFn:L});n&&O(e,n)}},A),U.type===g.Element&&U.tagName===`link`&&U.attributes.rel===`stylesheet`&&ce(e,function(){if(N){var t=me(e,{doc:n,mirror:r,blockClass:i,blockSelector:a,maskTextClass:o,maskTextSelector:s,skipChild:!1,inlineStylesheet:d,maskInputOptions:p,maskTextFn:m,maskInputFn:h,slimDOMOptions:b,dataURLOptions:S,inlineImages:w,recordCanvas:E,preserveWhiteSpace:V,onSerialize:D,onIframeLoad:O,iframeLoadTimeout:A,onStylesheetLoad:N,stylesheetLoadTimeout:F,keepIframeSrcFn:L});t&&N(e,t)}},F),U}function he(e,t){var n=t||{},r=n.mirror,i=r===void 0?new w:r,a=n.blockClass,o=a===void 0?`rr-block`:a,s=n.blockSelector,c=s===void 0?null:s,l=n.maskTextClass,u=l===void 0?`rr-mask`:l,d=n.maskTextSelector,f=d===void 0?null:d,p=n.inlineStylesheet,m=p===void 0?!0:p,h=n.inlineImages,g=h===void 0?!1:h,_=n.recordCanvas,v=_===void 0?!1:_,y=n.maskAllInputs,b=y===void 0?!1:y,x=n.maskTextFn,S=n.maskInputFn,C=n.slimDOM,T=C===void 0?!1:C,E=n.dataURLOptions,D=n.preserveWhiteSpace,O=n.onSerialize,k=n.onIframeLoad,A=n.iframeLoadTimeout,j=n.onStylesheetLoad,M=n.stylesheetLoadTimeout,N=n.keepIframeSrcFn,P=N===void 0?function(){return!1}:N;return me(e,{doc:e,mirror:i,blockClass:o,blockSelector:c,maskTextClass:u,maskTextSelector:f,skipChild:!1,inlineStylesheet:m,maskInputOptions:b===!0?{color:!0,date:!0,"datetime-local":!0,email:!0,month:!0,number:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0,textarea:!0,select:!0,password:!0}:b===!1?{password:!0}:b,maskTextFn:x,maskInputFn:S,slimDOMOptions:T===!0||T===`all`?{script:!0,comment:!0,headFavicon:!0,headWhitespace:!0,headMetaDescKeywords:T===`all`,headMetaSocial:!0,headMetaRobots:!0,headMetaHttpEquiv:!0,headMetaAuthorship:!0,headMetaVerification:!0}:T===!1?{}:T,dataURLOptions:E,inlineImages:g,recordCanvas:v,preserveWhiteSpace:D,onSerialize:O,onIframeLoad:k,iframeLoadTimeout:A,onStylesheetLoad:j,stylesheetLoadTimeout:M,keepIframeSrcFn:P,newlyAddedElement:!1})}function K(e,t,n=document){let r={capture:!0,passive:!0};return n.addEventListener(e,t,r),()=>n.removeEventListener(e,t,r)}let ge=`Please stop import mirror directly. Instead of that,\r
|
|
11
|
+
now you can use replayer.getMirror() to access the mirror instance of a replayer,\r
|
|
12
|
+
or you can use record.mirror to access the mirror instance during recording.`,_e={map:{},getId(){return console.error(ge),-1},getNode(){return console.error(ge),null},removeNodeFromMap(){console.error(ge)},has(){return console.error(ge),!1},reset(){console.error(ge)}};typeof window<`u`&&window.Proxy&&window.Reflect&&(_e=new Proxy(_e,{get(e,t,n){return t===`map`&&console.error(ge),Reflect.get(e,t,n)}}));function ve(e,t,n={}){let r=null,i=0;return function(...a){let o=Date.now();!i&&n.leading===!1&&(i=o);let s=t-(o-i),c=this;s<=0||s>t?(r&&=(clearTimeout(r),null),i=o,e.apply(c,a)):!r&&n.trailing!==!1&&(r=setTimeout(()=>{i=n.leading===!1?0:Date.now(),r=null,e.apply(c,a)},s))}}function ye(e,t,n,r,i=window){let a=i.Object.getOwnPropertyDescriptor(e,t);return i.Object.defineProperty(e,t,r?n:{set(e){setTimeout(()=>{n.set.call(this,e)},0),a&&a.set&&a.set.call(this,e)}}),()=>ye(e,t,a||{},!0)}function be(e,t,n){try{if(!(t in e))return()=>{};let r=e[t],i=n(r);return typeof i==`function`&&(i.prototype=i.prototype||{},Object.defineProperties(i,{__rrweb_original__:{enumerable:!1,value:r}})),e[t]=i,()=>{e[t]=r}}catch{return()=>{}}}function xe(){return window.innerHeight||document.documentElement&&document.documentElement.clientHeight||document.body&&document.body.clientHeight}function Se(){return window.innerWidth||document.documentElement&&document.documentElement.clientWidth||document.body&&document.body.clientWidth}function q(e,t,n,r){if(!e)return!1;let i=e.nodeType===e.ELEMENT_NODE?e:e.parentElement;if(!i)return!1;if(typeof t==`string`){if(i.classList.contains(t)||r&&i.closest(`.`+t)!==null)return!0}else if(oe(i,t,r))return!0;return!!(n&&(e.matches(n)||r&&i.closest(n)!==null))}function Ce(e,t){return t.getId(e)!==-1}function we(e,t){return t.getId(e)===j}function Te(e,t){if(v(e))return!1;let n=t.getId(e);return t.has(n)?e.parentNode&&e.parentNode.nodeType===e.DOCUMENT_NODE?!1:e.parentNode?Te(e.parentNode,t):!0:!0}function Ee(e){return!!e.changedTouches}function De(e=window){`NodeList`in e&&!e.NodeList.prototype.forEach&&(e.NodeList.prototype.forEach=Array.prototype.forEach),`DOMTokenList`in e&&!e.DOMTokenList.prototype.forEach&&(e.DOMTokenList.prototype.forEach=Array.prototype.forEach),Node.prototype.contains||(Node.prototype.contains=(...e)=>{let t=e[0];if(!(0 in e))throw TypeError(`1 argument is required`);do if(this===t)return!0;while(t&&=t.parentNode);return!1})}function Oe(e,t){return!!(e.nodeName===`IFRAME`&&t.getMeta(e))}function ke(e,t){return!!(e.nodeName===`LINK`&&e.nodeType===e.ELEMENT_NODE&&e.getAttribute&&e.getAttribute(`rel`)===`stylesheet`&&t.getMeta(e))}function Ae(e){return!!e?.shadowRoot}var je=class{constructor(){this.id=1,this.styleIDMap=new WeakMap,this.idStyleMap=new Map}getId(e){return this.styleIDMap.get(e)??-1}has(e){return this.styleIDMap.has(e)}add(e,t){if(this.has(e))return this.getId(e);let n;return n=t===void 0?this.id++:t,this.styleIDMap.set(e,n),this.idStyleMap.set(n,e),n}getStyle(e){return this.idStyleMap.get(e)||null}reset(){this.styleIDMap=new WeakMap,this.idStyleMap=new Map,this.id=1}generateId(){return this.id++}},J=(e=>(e[e.DomContentLoaded=0]=`DomContentLoaded`,e[e.Load=1]=`Load`,e[e.FullSnapshot=2]=`FullSnapshot`,e[e.IncrementalSnapshot=3]=`IncrementalSnapshot`,e[e.Meta=4]=`Meta`,e[e.Custom=5]=`Custom`,e[e.Plugin=6]=`Plugin`,e))(J||{}),Y=(e=>(e[e.Mutation=0]=`Mutation`,e[e.MouseMove=1]=`MouseMove`,e[e.MouseInteraction=2]=`MouseInteraction`,e[e.Scroll=3]=`Scroll`,e[e.ViewportResize=4]=`ViewportResize`,e[e.Input=5]=`Input`,e[e.TouchMove=6]=`TouchMove`,e[e.MediaInteraction=7]=`MediaInteraction`,e[e.StyleSheetRule=8]=`StyleSheetRule`,e[e.CanvasMutation=9]=`CanvasMutation`,e[e.Font=10]=`Font`,e[e.Log=11]=`Log`,e[e.Drag=12]=`Drag`,e[e.StyleDeclaration=13]=`StyleDeclaration`,e[e.Selection=14]=`Selection`,e[e.AdoptedStyleSheet=15]=`AdoptedStyleSheet`,e))(Y||{}),Me=(e=>(e[e.MouseUp=0]=`MouseUp`,e[e.MouseDown=1]=`MouseDown`,e[e.Click=2]=`Click`,e[e.ContextMenu=3]=`ContextMenu`,e[e.DblClick=4]=`DblClick`,e[e.Focus=5]=`Focus`,e[e.Blur=6]=`Blur`,e[e.TouchStart=7]=`TouchStart`,e[e.TouchMove_Departed=8]=`TouchMove_Departed`,e[e.TouchEnd=9]=`TouchEnd`,e[e.TouchCancel=10]=`TouchCancel`,e))(Me||{}),Ne=(e=>(e[e[`2D`]=0]=`2D`,e[e.WebGL=1]=`WebGL`,e[e.WebGL2=2]=`WebGL2`,e))(Ne||{});function Pe(e){return`__ln`in e}var Fe=class{constructor(){this.length=0,this.head=null}get(e){if(e>=this.length)throw Error(`Position outside of list range`);let t=this.head;for(let n=0;n<e;n++)t=t?.next||null;return t}addNode(e){let t={value:e,previous:null,next:null};if(e.__ln=t,e.previousSibling&&Pe(e.previousSibling)){let n=e.previousSibling.__ln.next;t.next=n,t.previous=e.previousSibling.__ln,e.previousSibling.__ln.next=t,n&&(n.previous=t)}else if(e.nextSibling&&Pe(e.nextSibling)&&e.nextSibling.__ln.previous){let n=e.nextSibling.__ln.previous;t.previous=n,t.next=e.nextSibling.__ln,e.nextSibling.__ln.previous=t,n&&(n.next=t)}else this.head&&(this.head.previous=t),t.next=this.head,this.head=t;this.length++}removeNode(e){let t=e.__ln;this.head&&(t.previous?(t.previous.next=t.next,t.next&&(t.next.previous=t.previous)):(this.head=t.next,this.head&&(this.head.previous=null)),e.__ln&&delete e.__ln,this.length--)}};let Ie=(e,t)=>`${e}@${t}`;var Le=class{constructor(){this.frozen=!1,this.locked=!1,this.texts=[],this.attributes=[],this.removes=[],this.mapRemoves=[],this.movedMap={},this.addedSet=new Set,this.movedSet=new Set,this.droppedSet=new Set,this.processMutations=e=>{e.forEach(this.processMutation),this.emit()},this.emit=()=>{if(this.frozen||this.locked)return;let e=[],t=new Fe,n=e=>{let t=e,n=j;for(;n===j;)t&&=t.nextSibling,n=t&&this.mirror.getId(t);return n},r=r=>{let i=null;r.getRootNode?.call(r)?.nodeType===Node.DOCUMENT_FRAGMENT_NODE&&r.getRootNode().host&&(i=r.getRootNode().host);let a=i;for(;(a?.getRootNode)?.call(a)?.nodeType===Node.DOCUMENT_FRAGMENT_NODE&&a.getRootNode().host;)a=a.getRootNode().host;let o=!this.doc.contains(r)&&(!a||!this.doc.contains(a));if(!r.parentNode||o)return;let s=v(r.parentNode)?this.mirror.getId(i):this.mirror.getId(r.parentNode),c=n(r);if(s===-1||c===-1)return t.addNode(r);let l=me(r,{doc:this.doc,mirror:this.mirror,blockClass:this.blockClass,blockSelector:this.blockSelector,maskTextClass:this.maskTextClass,maskTextSelector:this.maskTextSelector,skipChild:!0,newlyAddedElement:!0,inlineStylesheet:this.inlineStylesheet,maskInputOptions:this.maskInputOptions,maskTextFn:this.maskTextFn,maskInputFn:this.maskInputFn,slimDOMOptions:this.slimDOMOptions,dataURLOptions:this.dataURLOptions,recordCanvas:this.recordCanvas,inlineImages:this.inlineImages,onSerialize:e=>{Oe(e,this.mirror)&&this.iframeManager.addIframe(e),ke(e,this.mirror)&&this.stylesheetManager.trackLinkElement(e),Ae(r)&&this.shadowDomManager.addShadowRoot(r.shadowRoot,this.doc)},onIframeLoad:(e,t)=>{this.iframeManager.attachIframe(e,t),this.shadowDomManager.observeAttachShadow(e)},onStylesheetLoad:(e,t)=>{this.stylesheetManager.attachLinkElement(e,t)}});l&&e.push({parentId:s,nextId:c,node:l})};for(;this.mapRemoves.length;)this.mirror.removeNodeFromMap(this.mapRemoves.shift());for(let e of Array.from(this.movedSet.values()))ze(this.removes,e,this.mirror)&&!this.movedSet.has(e.parentNode)||r(e);for(let e of Array.from(this.addedSet.values()))!Ve(this.droppedSet,e)&&!ze(this.removes,e,this.mirror)||Ve(this.movedSet,e)?r(e):this.droppedSet.add(e);let i=null;for(;t.length;){let e=null;if(i){let t=this.mirror.getId(i.value.parentNode),r=n(i.value);t!==-1&&r!==-1&&(e=i)}if(!e)for(let r=t.length-1;r>=0;r--){let i=t.get(r);if(i){let t=this.mirror.getId(i.value.parentNode);if(n(i.value)===-1)continue;if(t!==-1){e=i;break}else{let t=i.value;if(t.parentNode&&t.parentNode.nodeType===Node.DOCUMENT_FRAGMENT_NODE){let n=t.parentNode.host;if(this.mirror.getId(n)!==-1){e=i;break}}}}}if(!e){for(;t.head;)t.removeNode(t.head.value);break}i=e.previous,t.removeNode(e.value),r(e.value)}let a={texts:this.texts.map(e=>({id:this.mirror.getId(e.node),value:e.value})).filter(e=>this.mirror.has(e.id)),attributes:this.attributes.map(e=>({id:this.mirror.getId(e.node),attributes:e.attributes})).filter(e=>this.mirror.has(e.id)),removes:this.removes,adds:e};!a.texts.length&&!a.attributes.length&&!a.removes.length&&!a.adds.length||(this.texts=[],this.attributes=[],this.removes=[],this.addedSet=new Set,this.movedSet=new Set,this.droppedSet=new Set,this.movedMap={},this.mutationCb(a))},this.processMutation=e=>{if(!we(e.target,this.mirror))switch(e.type){case`characterData`:{let t=e.target.textContent;!q(e.target,this.blockClass,this.blockSelector,!1)&&t!==e.oldValue&&this.texts.push({value:W(e.target,this.maskTextClass,this.maskTextSelector)&&t?this.maskTextFn?this.maskTextFn(t):t.replace(/[\S]/g,`*`):t,node:e.target});break}case`attributes`:{let t=e.target,n=e.target.getAttribute(e.attributeName);if(e.attributeName===`value`&&(n=E({maskInputOptions:this.maskInputOptions,tagName:e.target.tagName,type:e.target.getAttribute(`type`),value:n,maskInputFn:this.maskInputFn})),q(e.target,this.blockClass,this.blockSelector,!1)||n===e.oldValue)return;let r=this.attributes.find(t=>t.node===e.target);if(t.tagName===`IFRAME`&&e.attributeName===`src`&&!this.keepIframeSrcFn(n))if(!t.contentDocument)e.attributeName=`rr_src`;else return;if(r||(r={node:e.target,attributes:{}},this.attributes.push(r)),e.attributeName===`style`){let n=this.doc.createElement(`span`);e.oldValue&&n.setAttribute(`style`,e.oldValue),(r.attributes.style===void 0||r.attributes.style===null)&&(r.attributes.style={});let i=r.attributes.style;for(let e of Array.from(t.style)){let r=t.style.getPropertyValue(e),a=t.style.getPropertyPriority(e);(r!==n.style.getPropertyValue(e)||a!==n.style.getPropertyPriority(e))&&(a===``?i[e]=r:i[e]=[r,a])}for(let e of Array.from(n.style))t.style.getPropertyValue(e)===``&&(i[e]=!1)}else r.attributes[e.attributeName]=ie(this.doc,t.tagName,e.attributeName,n);break}case`childList`:if(q(e.target,this.blockClass,this.blockSelector,!0))return;e.addedNodes.forEach(t=>this.genAdds(t,e.target)),e.removedNodes.forEach(t=>{let n=this.mirror.getId(t),r=v(e.target)?this.mirror.getId(e.target.host):this.mirror.getId(e.target);q(e.target,this.blockClass,this.blockSelector,!1)||we(t,this.mirror)||!Ce(t,this.mirror)||(this.addedSet.has(t)?(Re(this.addedSet,t),this.droppedSet.add(t)):this.addedSet.has(e.target)&&n===-1||Te(e.target,this.mirror)||(this.movedSet.has(t)&&this.movedMap[Ie(n,r)]?Re(this.movedSet,t):this.removes.push({parentId:r,id:n,isShadow:v(e.target)&&y(e.target)?!0:void 0})),this.mapRemoves.push(t))});break}},this.genAdds=(e,t)=>{if(this.mirror.hasNode(e)){if(we(e,this.mirror))return;this.movedSet.add(e);let n=null;t&&this.mirror.hasNode(t)&&(n=this.mirror.getId(t)),n&&n!==-1&&(this.movedMap[Ie(this.mirror.getId(e),n)]=!0)}else this.addedSet.add(e),this.droppedSet.delete(e);q(e,this.blockClass,this.blockSelector,!1)||e.childNodes.forEach(e=>this.genAdds(e))}}init(e){[`mutationCb`,`blockClass`,`blockSelector`,`maskTextClass`,`maskTextSelector`,`inlineStylesheet`,`maskInputOptions`,`maskTextFn`,`maskInputFn`,`keepIframeSrcFn`,`recordCanvas`,`inlineImages`,`slimDOMOptions`,`dataURLOptions`,`doc`,`mirror`,`iframeManager`,`stylesheetManager`,`shadowDomManager`,`canvasManager`].forEach(t=>{this[t]=e[t]})}freeze(){this.frozen=!0,this.canvasManager.freeze()}unfreeze(){this.frozen=!1,this.canvasManager.unfreeze(),this.emit()}isFrozen(){return this.frozen}lock(){this.locked=!0,this.canvasManager.lock()}unlock(){this.locked=!1,this.canvasManager.unlock(),this.emit()}reset(){this.shadowDomManager.reset(),this.canvasManager.reset()}};function Re(e,t){e.delete(t),t.childNodes.forEach(t=>Re(e,t))}function ze(e,t,n){return e.length===0?!1:Be(e,t,n)}function Be(e,t,n){let{parentNode:r}=t;if(!r)return!1;let i=n.getId(r);return e.some(e=>e.id===i)?!0:Be(e,r,n)}function Ve(e,t){return e.size===0?!1:He(e,t)}function He(e,t){let{parentNode:n}=t;return n?e.has(n)?!0:He(e,n):!1}let Ue=[],We=typeof CSSGroupingRule<`u`,Ge=typeof CSSMediaRule<`u`,Ke=typeof CSSSupportsRule<`u`,qe=typeof CSSConditionRule<`u`;function Je(e){try{if(`composedPath`in e){let t=e.composedPath();if(t.length)return t[0]}else if(`path`in e&&e.path.length)return e.path[0];return e.target}catch{return e.target}}function Ye(e,t){var n;let r=new Le;Ue.push(r),r.init(e);let i=window.MutationObserver||window.__rrMutationObserver,a=((n=window==null?void 0:window.Zone)?.__symbol__)?.call(n,`MutationObserver`);a&&window[a]&&(i=window[a]);let o=new i(r.processMutations.bind(r));return o.observe(t,{attributes:!0,attributeOldValue:!0,characterData:!0,characterDataOldValue:!0,childList:!0,subtree:!0}),o}function Xe({mousemoveCb:e,sampling:t,doc:n,mirror:r}){if(t.mousemove===!1)return()=>{};let i=typeof t.mousemove==`number`?t.mousemove:50,a=typeof t.mousemoveCallback==`number`?t.mousemoveCallback:500,o=[],s,c=ve(t=>{let n=Date.now()-s;e(o.map(e=>(e.timeOffset-=n,e)),t),o=[],s=null},a),l=ve(e=>{let t=Je(e),{clientX:n,clientY:i}=Ee(e)?e.changedTouches[0]:e;s||=Date.now(),o.push({x:n,y:i,id:r.getId(t),timeOffset:Date.now()-s}),c(typeof DragEvent<`u`&&e instanceof DragEvent?Y.Drag:e instanceof MouseEvent?Y.MouseMove:Y.TouchMove)},i,{trailing:!1}),u=[K(`mousemove`,l,n),K(`touchmove`,l,n),K(`drag`,l,n)];return()=>{u.forEach(e=>e())}}function Ze({mouseInteractionCb:e,doc:t,mirror:n,blockClass:r,blockSelector:i,sampling:a}){if(a.mouseInteraction===!1)return()=>{};let o=a.mouseInteraction===!0||a.mouseInteraction===void 0?{}:a.mouseInteraction,s=[],c=t=>a=>{let o=Je(a);if(q(o,r,i,!0))return;let s=Ee(a)?a.changedTouches[0]:a;if(!s)return;let c=n.getId(o),{clientX:l,clientY:u}=s;e({type:Me[t],id:c,x:l,y:u})};return Object.keys(Me).filter(e=>Number.isNaN(Number(e))&&!e.endsWith(`_Departed`)&&o[e]!==!1).forEach(e=>{let n=e.toLowerCase(),r=c(e);s.push(K(n,r,t))}),()=>{s.forEach(e=>e())}}function Qe({scrollCb:e,doc:t,mirror:n,blockClass:r,blockSelector:i,sampling:a}){return K(`scroll`,ve(a=>{let o=Je(a);if(!o||q(o,r,i,!0))return;let s=n.getId(o);if(o===t){let n=t.scrollingElement||t.documentElement;e({id:s,x:n.scrollLeft,y:n.scrollTop})}else e({id:s,x:o.scrollLeft,y:o.scrollTop})},a.scroll||100),t)}function $e({viewportResizeCb:e}){let t=-1,n=-1;return K(`resize`,ve(()=>{let r=xe(),i=Se();(t!==r||n!==i)&&(e({width:Number(i),height:Number(r)}),t=r,n=i)},200),window)}function et(e,t){let n=Object.assign({},e);return t||delete n.userTriggered,n}let tt=[`INPUT`,`TEXTAREA`,`SELECT`],nt=new WeakMap;function rt({inputCb:e,doc:t,mirror:n,blockClass:r,blockSelector:i,ignoreClass:a,maskInputOptions:o,maskInputFn:s,sampling:c,userTriggeredOnInput:l}){function u(e){let n=Je(e),c=e.isTrusted;if(n&&n.tagName===`OPTION`&&(n=n.parentElement),!n||!n.tagName||tt.indexOf(n.tagName)<0||q(n,r,i,!0))return;let u=n.type;if(n.classList.contains(a))return;let f=n.value,p=!1;u===`radio`||u===`checkbox`?p=n.checked:(o[n.tagName.toLowerCase()]||o[u])&&(f=E({maskInputOptions:o,tagName:n.tagName,type:u,value:f,maskInputFn:s})),d(n,et({text:f,isChecked:p,userTriggered:c},l));let m=n.name;u===`radio`&&m&&p&&t.querySelectorAll(`input[type="radio"][name="${m}"]`).forEach(e=>{e!==n&&d(e,et({text:e.value,isChecked:!p,userTriggered:!1},l))})}function d(t,r){let i=nt.get(t);if(!i||i.text!==r.text||i.isChecked!==r.isChecked){nt.set(t,r);let i=n.getId(t);e(Object.assign(Object.assign({},r),{id:i}))}}let f=(c.input===`last`?[`change`]:[`input`,`change`]).map(e=>K(e,u,t)),p=t.defaultView;if(!p)return()=>{f.forEach(e=>e())};let m=p.Object.getOwnPropertyDescriptor(p.HTMLInputElement.prototype,`value`),h=[[p.HTMLInputElement.prototype,`value`],[p.HTMLInputElement.prototype,`checked`],[p.HTMLSelectElement.prototype,`value`],[p.HTMLTextAreaElement.prototype,`value`],[p.HTMLSelectElement.prototype,`selectedIndex`],[p.HTMLOptionElement.prototype,`selected`]];return m&&m.set&&f.push(...h.map(e=>ye(e[0],e[1],{set(){u({target:this})}},!1,p))),()=>{f.forEach(e=>e())}}function it(e){let t=[];function n(e,t){if(We&&e.parentRule instanceof CSSGroupingRule||Ge&&e.parentRule instanceof CSSMediaRule||Ke&&e.parentRule instanceof CSSSupportsRule||qe&&e.parentRule instanceof CSSConditionRule){let n=Array.from(e.parentRule.cssRules).indexOf(e);t.unshift(n)}else if(e.parentStyleSheet){let n=Array.from(e.parentStyleSheet.cssRules).indexOf(e);t.unshift(n)}return t}return n(e,t)}function X(e,t,n){let r,i;return e?(e.ownerNode?r=t.getId(e.ownerNode):i=n.getId(e),{styleId:i,id:r}):{}}function at({styleSheetRuleCb:e,mirror:t,stylesheetManager:n},{win:r}){let i=r.CSSStyleSheet.prototype.insertRule;r.CSSStyleSheet.prototype.insertRule=function(r,a){let{id:o,styleId:s}=X(this,t,n.styleMirror);return(o&&o!==-1||s&&s!==-1)&&e({id:o,styleId:s,adds:[{rule:r,index:a}]}),i.apply(this,[r,a])};let a=r.CSSStyleSheet.prototype.deleteRule;r.CSSStyleSheet.prototype.deleteRule=function(r){let{id:i,styleId:o}=X(this,t,n.styleMirror);return(i&&i!==-1||o&&o!==-1)&&e({id:i,styleId:o,removes:[{index:r}]}),a.apply(this,[r])};let o;r.CSSStyleSheet.prototype.replace&&(o=r.CSSStyleSheet.prototype.replace,r.CSSStyleSheet.prototype.replace=function(r){let{id:i,styleId:a}=X(this,t,n.styleMirror);return(i&&i!==-1||a&&a!==-1)&&e({id:i,styleId:a,replace:r}),o.apply(this,[r])});let s;r.CSSStyleSheet.prototype.replaceSync&&(s=r.CSSStyleSheet.prototype.replaceSync,r.CSSStyleSheet.prototype.replaceSync=function(r){let{id:i,styleId:a}=X(this,t,n.styleMirror);return(i&&i!==-1||a&&a!==-1)&&e({id:i,styleId:a,replaceSync:r}),s.apply(this,[r])});let c={};We?c.CSSGroupingRule=r.CSSGroupingRule:(Ge&&(c.CSSMediaRule=r.CSSMediaRule),qe&&(c.CSSConditionRule=r.CSSConditionRule),Ke&&(c.CSSSupportsRule=r.CSSSupportsRule));let l={};return Object.entries(c).forEach(([r,i])=>{l[r]={insertRule:i.prototype.insertRule,deleteRule:i.prototype.deleteRule},i.prototype.insertRule=function(i,a){let{id:o,styleId:s}=X(this.parentStyleSheet,t,n.styleMirror);return(o&&o!==-1||s&&s!==-1)&&e({id:o,styleId:s,adds:[{rule:i,index:[...it(this),a||0]}]}),l[r].insertRule.apply(this,[i,a])},i.prototype.deleteRule=function(i){let{id:a,styleId:o}=X(this.parentStyleSheet,t,n.styleMirror);return(a&&a!==-1||o&&o!==-1)&&e({id:a,styleId:o,removes:[{index:[...it(this),i]}]}),l[r].deleteRule.apply(this,[i])}}),()=>{r.CSSStyleSheet.prototype.insertRule=i,r.CSSStyleSheet.prototype.deleteRule=a,o&&(r.CSSStyleSheet.prototype.replace=o),s&&(r.CSSStyleSheet.prototype.replaceSync=s),Object.entries(c).forEach(([e,t])=>{t.prototype.insertRule=l[e].insertRule,t.prototype.deleteRule=l[e].deleteRule})}}function ot({mirror:e,stylesheetManager:t},n){let r=null;r=n.nodeName===`#document`?e.getId(n):e.getId(n.host);let i=n.nodeName===`#document`?n.defaultView?.Document:n.ownerDocument?.defaultView?.ShadowRoot,a=Object.getOwnPropertyDescriptor(i?.prototype,`adoptedStyleSheets`);return r===null||r===-1||!i||!a?()=>{}:(Object.defineProperty(n,`adoptedStyleSheets`,{configurable:a.configurable,enumerable:a.enumerable,get(){return a.get?.call(this)},set(e){let n=a.set?.call(this,e);if(r!==null&&r!==-1)try{t.adoptStyleSheets(e,r)}catch{}return n}}),()=>{Object.defineProperty(n,`adoptedStyleSheets`,{configurable:a.configurable,enumerable:a.enumerable,get:a.get,set:a.set})})}function st({styleDeclarationCb:e,mirror:t,ignoreCSSAttributes:n,stylesheetManager:r},{win:i}){let a=i.CSSStyleDeclaration.prototype.setProperty;i.CSSStyleDeclaration.prototype.setProperty=function(i,o,s){if(n.has(i))return a.apply(this,[i,o,s]);let{id:c,styleId:l}=X(this.parentRule?.parentStyleSheet,t,r.styleMirror);return(c&&c!==-1||l&&l!==-1)&&e({id:c,styleId:l,set:{property:i,value:o,priority:s},index:it(this.parentRule)}),a.apply(this,[i,o,s])};let o=i.CSSStyleDeclaration.prototype.removeProperty;return i.CSSStyleDeclaration.prototype.removeProperty=function(i){if(n.has(i))return o.apply(this,[i]);let{id:a,styleId:s}=X(this.parentRule?.parentStyleSheet,t,r.styleMirror);return(a&&a!==-1||s&&s!==-1)&&e({id:a,styleId:s,remove:{property:i},index:it(this.parentRule)}),o.apply(this,[i])},()=>{i.CSSStyleDeclaration.prototype.setProperty=a,i.CSSStyleDeclaration.prototype.removeProperty=o}}function ct({mediaInteractionCb:e,blockClass:t,blockSelector:n,mirror:r,sampling:i}){let a=a=>ve(i=>{let o=Je(i);if(!o||q(o,t,n,!0))return;let{currentTime:s,volume:c,muted:l,playbackRate:u}=o;e({type:a,id:r.getId(o),currentTime:s,volume:c,muted:l,playbackRate:u})},i.media||500),o=[K(`play`,a(0)),K(`pause`,a(1)),K(`seeked`,a(2)),K(`volumechange`,a(3)),K(`ratechange`,a(4))];return()=>{o.forEach(e=>e())}}function lt({fontCb:e,doc:t}){let n=t.defaultView;if(!n)return()=>{};let r=[],i=new WeakMap,a=n.FontFace;n.FontFace=function(e,t,n){let r=new a(e,t,n);return i.set(r,{family:e,buffer:typeof t!=`string`,descriptors:n,fontSource:typeof t==`string`?t:JSON.stringify(Array.from(new Uint8Array(t)))}),r};let o=be(t.fonts,`add`,function(t){return function(n){return setTimeout(()=>{let t=i.get(n);t&&(e(t),i.delete(n))},0),t.apply(this,[n])}});return r.push(()=>{n.FontFace=a}),r.push(o),()=>{r.forEach(e=>e())}}function ut(e){let{doc:t,mirror:n,blockClass:r,blockSelector:i,selectionCb:a}=e,o=!0,s=()=>{let e=t.getSelection();if(!e||o&&e?.isCollapsed)return;o=e.isCollapsed||!1;let s=[],c=e.rangeCount||0;for(let t=0;t<c;t++){let{startContainer:a,startOffset:o,endContainer:c,endOffset:l}=e.getRangeAt(t);q(a,r,i,!0)||q(c,r,i,!0)||s.push({start:n.getId(a),startOffset:o,end:n.getId(c),endOffset:l})}a({ranges:s})};return s(),K(`selectionchange`,s)}function dt(e,t){let{mutationCb:n,mousemoveCb:r,mouseInteractionCb:i,scrollCb:a,viewportResizeCb:o,inputCb:s,mediaInteractionCb:c,styleSheetRuleCb:l,styleDeclarationCb:u,canvasMutationCb:d,fontCb:f,selectionCb:p}=e;e.mutationCb=(...e)=>{t.mutation&&t.mutation(...e),n(...e)},e.mousemoveCb=(...e)=>{t.mousemove&&t.mousemove(...e),r(...e)},e.mouseInteractionCb=(...e)=>{t.mouseInteraction&&t.mouseInteraction(...e),i(...e)},e.scrollCb=(...e)=>{t.scroll&&t.scroll(...e),a(...e)},e.viewportResizeCb=(...e)=>{t.viewportResize&&t.viewportResize(...e),o(...e)},e.inputCb=(...e)=>{t.input&&t.input(...e),s(...e)},e.mediaInteractionCb=(...e)=>{t.mediaInteaction&&t.mediaInteaction(...e),c(...e)},e.styleSheetRuleCb=(...e)=>{t.styleSheetRule&&t.styleSheetRule(...e),l(...e)},e.styleDeclarationCb=(...e)=>{t.styleDeclaration&&t.styleDeclaration(...e),u(...e)},e.canvasMutationCb=(...e)=>{t.canvasMutation&&t.canvasMutation(...e),d(...e)},e.fontCb=(...e)=>{t.font&&t.font(...e),f(...e)},e.selectionCb=(...e)=>{t.selection&&t.selection(...e),p(...e)}}function ft(e,t={}){let n=e.doc.defaultView;if(!n)return()=>{};dt(e,t);let r=Ye(e,e.doc),i=Xe(e),a=Ze(e),o=Qe(e),s=$e(e),c=rt(e),l=ct(e),u=at(e,{win:n}),d=ot(e,e.doc),f=st(e,{win:n}),p=e.collectFonts?lt(e):()=>{},m=ut(e),h=[];for(let t of e.plugins)h.push(t.observer(t.callback,n,t.options));return()=>{Ue.forEach(e=>e.reset()),r.disconnect(),i(),a(),o(),s(),c(),l(),u(),d(),f(),p(),m(),h.forEach(e=>e())}}var pt=class{constructor(e){this.generateIdFn=e,this.iframeIdToRemoteIdMap=new WeakMap,this.iframeRemoteIdToIdMap=new WeakMap}getId(e,t,n,r){let i=n||this.getIdToRemoteIdMap(e),a=r||this.getRemoteIdToIdMap(e),o=i.get(t);return o||(o=this.generateIdFn(),i.set(t,o),a.set(o,t)),o}getIds(e,t){let n=this.getIdToRemoteIdMap(e),r=this.getRemoteIdToIdMap(e);return t.map(t=>this.getId(e,t,n,r))}getRemoteId(e,t,n){let r=n||this.getRemoteIdToIdMap(e);return typeof t==`number`?r.get(t)||-1:t}getRemoteIds(e,t){let n=this.getRemoteIdToIdMap(e);return t.map(t=>this.getRemoteId(e,t,n))}reset(e){if(!e){this.iframeIdToRemoteIdMap=new WeakMap,this.iframeRemoteIdToIdMap=new WeakMap;return}this.iframeIdToRemoteIdMap.delete(e),this.iframeRemoteIdToIdMap.delete(e)}getIdToRemoteIdMap(e){let t=this.iframeIdToRemoteIdMap.get(e);return t||(t=new Map,this.iframeIdToRemoteIdMap.set(e,t)),t}getRemoteIdToIdMap(e){let t=this.iframeRemoteIdToIdMap.get(e);return t||(t=new Map,this.iframeRemoteIdToIdMap.set(e,t)),t}},mt=class{constructor(e){this.iframes=new WeakMap,this.crossOriginIframeMap=new WeakMap,this.crossOriginIframeMirror=new pt(M),this.mutationCb=e.mutationCb,this.wrappedEmit=e.wrappedEmit,this.stylesheetManager=e.stylesheetManager,this.recordCrossOriginIframes=e.recordCrossOriginIframes,this.crossOriginIframeStyleMirror=new pt(this.stylesheetManager.styleMirror.generateId.bind(this.stylesheetManager.styleMirror)),this.mirror=e.mirror,this.recordCrossOriginIframes&&window.addEventListener(`message`,this.handleMessage.bind(this))}addIframe(e){this.iframes.set(e,!0),e.contentWindow&&this.crossOriginIframeMap.set(e.contentWindow,e)}addLoadListener(e){this.loadListener=e}attachIframe(e,t){var n;this.mutationCb({adds:[{parentId:this.mirror.getId(e),nextId:null,node:t}],removes:[],texts:[],attributes:[],isAttachIframe:!0}),(n=this.loadListener)==null||n.call(this,e),e.contentDocument&&e.contentDocument.adoptedStyleSheets&&e.contentDocument.adoptedStyleSheets.length>0&&this.stylesheetManager.adoptStyleSheets(e.contentDocument.adoptedStyleSheets,this.mirror.getId(e.contentDocument))}handleMessage(e){if(e.data.type===`rrweb`){if(!e.source)return;let t=this.crossOriginIframeMap.get(e.source);if(!t)return;let n=this.transformCrossOriginEvent(t,e.data.event);n&&this.wrappedEmit(n,e.data.isCheckout)}}transformCrossOriginEvent(e,t){var n;switch(t.type){case J.FullSnapshot:return this.crossOriginIframeMirror.reset(e),this.crossOriginIframeStyleMirror.reset(e),this.replaceIdOnNode(t.data.node,e),{timestamp:t.timestamp,type:J.IncrementalSnapshot,data:{source:Y.Mutation,adds:[{parentId:this.mirror.getId(e),nextId:null,node:t.data.node}],removes:[],texts:[],attributes:[],isAttachIframe:!0}};case J.Meta:case J.Load:case J.DomContentLoaded:return!1;case J.Plugin:return t;case J.Custom:return this.replaceIds(t.data.payload,e,[`id`,`parentId`,`previousId`,`nextId`]),t;case J.IncrementalSnapshot:switch(t.data.source){case Y.Mutation:return t.data.adds.forEach(t=>{this.replaceIds(t,e,[`parentId`,`nextId`,`previousId`]),this.replaceIdOnNode(t.node,e)}),t.data.removes.forEach(t=>{this.replaceIds(t,e,[`parentId`,`id`])}),t.data.attributes.forEach(t=>{this.replaceIds(t,e,[`id`])}),t.data.texts.forEach(t=>{this.replaceIds(t,e,[`id`])}),t;case Y.Drag:case Y.TouchMove:case Y.MouseMove:return t.data.positions.forEach(t=>{this.replaceIds(t,e,[`id`])}),t;case Y.ViewportResize:return!1;case Y.MediaInteraction:case Y.MouseInteraction:case Y.Scroll:case Y.CanvasMutation:case Y.Input:return this.replaceIds(t.data,e,[`id`]),t;case Y.StyleSheetRule:case Y.StyleDeclaration:return this.replaceIds(t.data,e,[`id`]),this.replaceStyleIds(t.data,e,[`styleId`]),t;case Y.Font:return t;case Y.Selection:return t.data.ranges.forEach(t=>{this.replaceIds(t,e,[`start`,`end`])}),t;case Y.AdoptedStyleSheet:return this.replaceIds(t.data,e,[`id`]),this.replaceStyleIds(t.data,e,[`styleIds`]),(n=t.data.styles)==null||n.forEach(t=>{this.replaceStyleIds(t,e,[`styleId`])}),t}}}replace(e,t,n,r){for(let i of r)!Array.isArray(t[i])&&typeof t[i]!=`number`||(Array.isArray(t[i])?t[i]=e.getIds(n,t[i]):t[i]=e.getId(n,t[i]));return t}replaceIds(e,t,n){return this.replace(this.crossOriginIframeMirror,e,t,n)}replaceStyleIds(e,t,n){return this.replace(this.crossOriginIframeStyleMirror,e,t,n)}replaceIdOnNode(e,t){this.replaceIds(e,t,[`id`]),`childNodes`in e&&e.childNodes.forEach(e=>{this.replaceIdOnNode(e,t)})}},ht=class{constructor(e){this.shadowDoms=new WeakSet,this.restorePatches=[],this.mutationCb=e.mutationCb,this.scrollCb=e.scrollCb,this.bypassOptions=e.bypassOptions,this.mirror=e.mirror;let t=this;this.restorePatches.push(be(Element.prototype,`attachShadow`,function(e){return function(n){let r=e.call(this,n);return this.shadowRoot&&t.addShadowRoot(this.shadowRoot,this.ownerDocument),r}}))}addShadowRoot(e,t){y(e)&&(this.shadowDoms.has(e)||(this.shadowDoms.add(e),Ye(Object.assign(Object.assign({},this.bypassOptions),{doc:t,mutationCb:this.mutationCb,mirror:this.mirror,shadowDomManager:this}),e),Qe(Object.assign(Object.assign({},this.bypassOptions),{scrollCb:this.scrollCb,doc:e,mirror:this.mirror})),setTimeout(()=>{e.adoptedStyleSheets&&e.adoptedStyleSheets.length>0&&this.bypassOptions.stylesheetManager.adoptStyleSheets(e.adoptedStyleSheets,this.mirror.getId(e.host)),ot({mirror:this.mirror,stylesheetManager:this.bypassOptions.stylesheetManager},e)},0)))}observeAttachShadow(e){if(e.contentWindow){let t=this;this.restorePatches.push(be(e.contentWindow.HTMLElement.prototype,`attachShadow`,function(n){return function(r){let i=n.call(this,r);return this.shadowRoot&&t.addShadowRoot(this.shadowRoot,e.contentDocument),i}}))}}reset(){this.restorePatches.forEach(e=>e()),this.shadowDoms=new WeakSet}};
|
|
13
|
+
/*! *****************************************************************************
|
|
14
|
+
Copyright (c) Microsoft Corporation.
|
|
15
|
+
|
|
16
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
17
|
+
purpose with or without fee is hereby granted.
|
|
18
|
+
|
|
19
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
20
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
21
|
+
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
22
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
23
|
+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
24
|
+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
25
|
+
PERFORMANCE OF THIS SOFTWARE.
|
|
26
|
+
***************************************************************************** */
|
|
27
|
+
function gt(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols==`function`)for(var i=0,r=Object.getOwnPropertySymbols(e);i<r.length;i++)t.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(e,r[i])&&(n[r[i]]=e[r[i]]);return n}function _t(e,t,n,r){function i(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||=Promise)(function(n,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){e.done?n(e.value):i(e.value).then(o,s)}c((r=r.apply(e,t||[])).next())})}for(var vt=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/`,yt=typeof Uint8Array>`u`?[]:new Uint8Array(256),bt=0;bt<vt.length;bt++)yt[vt.charCodeAt(bt)]=bt;var xt=function(e){var t=new Uint8Array(e),n,r=t.length,i=``;for(n=0;n<r;n+=3)i+=vt[t[n]>>2],i+=vt[(t[n]&3)<<4|t[n+1]>>4],i+=vt[(t[n+1]&15)<<2|t[n+2]>>6],i+=vt[t[n+2]&63];return r%3==2?i=i.substring(0,i.length-1)+`=`:r%3==1&&(i=i.substring(0,i.length-2)+`==`),i};let St=new Map;function Ct(e,t){let n=St.get(e);return n||(n=new Map,St.set(e,n)),n.has(t)||n.set(t,[]),n.get(t)}let wt=(e,t,n)=>{if(!e||!(Dt(e,t)||typeof e==`object`))return;let r=e.constructor.name,i=Ct(n,r),a=i.indexOf(e);return a===-1&&(a=i.length,i.push(e)),a};function Tt(e,t,n){if(e instanceof Array)return e.map(e=>Tt(e,t,n));if(e===null)return e;if(e instanceof Float32Array||e instanceof Float64Array||e instanceof Int32Array||e instanceof Uint32Array||e instanceof Uint8Array||e instanceof Uint16Array||e instanceof Int16Array||e instanceof Int8Array||e instanceof Uint8ClampedArray)return{rr_type:e.constructor.name,args:[Object.values(e)]};if(e instanceof ArrayBuffer)return{rr_type:e.constructor.name,base64:xt(e)};if(e instanceof DataView)return{rr_type:e.constructor.name,args:[Tt(e.buffer,t,n),e.byteOffset,e.byteLength]};if(e instanceof HTMLImageElement){let t=e.constructor.name,{src:n}=e;return{rr_type:t,src:n}}else if(e instanceof HTMLCanvasElement)return{rr_type:`HTMLImageElement`,src:e.toDataURL()};else if(e instanceof ImageData)return{rr_type:e.constructor.name,args:[Tt(e.data,t,n),e.width,e.height]};else if(Dt(e,t)||typeof e==`object`)return{rr_type:e.constructor.name,index:wt(e,t,n)};return e}let Et=(e,t,n)=>[...e].map(e=>Tt(e,t,n)),Dt=(e,t)=>!![`WebGLActiveInfo`,`WebGLBuffer`,`WebGLFramebuffer`,`WebGLProgram`,`WebGLRenderbuffer`,`WebGLShader`,`WebGLShaderPrecisionFormat`,`WebGLTexture`,`WebGLUniformLocation`,`WebGLVertexArrayObject`,`WebGLVertexArrayObjectOES`].filter(e=>typeof t[e]==`function`).find(n=>e instanceof t[n]);function Ot(e,t,n,r){let i=[],a=Object.getOwnPropertyNames(t.CanvasRenderingContext2D.prototype);for(let o of a)try{if(typeof t.CanvasRenderingContext2D.prototype[o]!=`function`)continue;let a=be(t.CanvasRenderingContext2D.prototype,o,function(i){return function(...a){return q(this.canvas,n,r,!0)||setTimeout(()=>{let n=Et([...a],t,this);e(this.canvas,{type:Ne[`2D`],property:o,args:n})},0),i.apply(this,a)}});i.push(a)}catch{let n=ye(t.CanvasRenderingContext2D.prototype,o,{set(t){e(this.canvas,{type:Ne[`2D`],property:o,args:[t],setter:!0})}});i.push(n)}return()=>{i.forEach(e=>e())}}function kt(e,t,n){let r=[];try{let i=be(e.HTMLCanvasElement.prototype,`getContext`,function(e){return function(r,...i){return q(this,t,n,!0)||`__context`in this||(this.__context=r),e.apply(this,[r,...i])}});r.push(i)}catch{console.error(`failed to patch HTMLCanvasElement.prototype.getContext`)}return()=>{r.forEach(e=>e())}}function At(e,t,n,r,i,a,o){let s=[],c=Object.getOwnPropertyNames(e);for(let a of c)if(![`isContextLost`,`canvas`,`drawingBufferWidth`,`drawingBufferHeight`].includes(a))try{if(typeof e[a]!=`function`)continue;let c=be(e,a,function(e){return function(...s){let c=e.apply(this,s);if(wt(c,o,this),!q(this.canvas,r,i,!0)){let e={type:t,property:a,args:Et([...s],o,this)};n(this.canvas,e)}return c}});s.push(c)}catch{let r=ye(e,a,{set(e){n(this.canvas,{type:t,property:a,args:[e],setter:!0})}});s.push(r)}return s}function jt(e,t,n,r,i){let a=[];return a.push(...At(t.WebGLRenderingContext.prototype,Ne.WebGL,e,n,r,i,t)),t.WebGL2RenderingContext!==void 0&&a.push(...At(t.WebGL2RenderingContext.prototype,Ne.WebGL2,e,n,r,i,t)),()=>{a.forEach(e=>e())}}var Mt=null;try{Mt=(typeof module<`u`&&typeof module.require==`function`&&module.require(`worker_threads`)||typeof __non_webpack_require__==`function`&&__non_webpack_require__(`worker_threads`)||typeof require==`function`&&require(`worker_threads`)).Worker}catch{}function Nt(e,t){return Buffer.from(e,`base64`).toString(t?`utf16`:`utf8`)}function Pt(e,t,n){var r=t===void 0?null:t,i=Nt(e,n===void 0?!1:n),a=i.indexOf(`
|
|
28
|
+
`,10)+1,o=i.substring(a)+(r?`//# sourceMappingURL=`+r:``);return function(e){return new Mt(o,Object.assign({},e,{eval:!0}))}}function Ft(e,t){var n=atob(e);if(t){for(var r=new Uint8Array(n.length),i=0,a=n.length;i<a;++i)r[i]=n.charCodeAt(i);return String.fromCharCode.apply(null,new Uint16Array(r.buffer))}return n}function It(e,t,n){var r=t===void 0?null:t,i=Ft(e,n===void 0?!1:n),a=i.indexOf(`
|
|
29
|
+
`,10)+1,o=i.substring(a)+(r?`//# sourceMappingURL=`+r:``),s=new Blob([o],{type:`application/javascript`});return URL.createObjectURL(s)}function Lt(e,t,n){var r;return function(i){return r||=It(e,t,n),new Worker(r,i)}}var Rt=Object.prototype.toString.call(typeof process<`u`?process:0)===`[object process]`;function zt(){return Rt}function Bt(e,t,n){return zt()?Pt(e,t,n):Lt(e,t,n)}var Vt=Bt(`Lyogcm9sbHVwLXBsdWdpbi13ZWItd29ya2VyLWxvYWRlciAqLwooZnVuY3Rpb24gKCkgewogICAgJ3VzZSBzdHJpY3QnOwoKICAgIC8qISAqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKg0KICAgIENvcHlyaWdodCAoYykgTWljcm9zb2Z0IENvcnBvcmF0aW9uLg0KDQogICAgUGVybWlzc2lvbiB0byB1c2UsIGNvcHksIG1vZGlmeSwgYW5kL29yIGRpc3RyaWJ1dGUgdGhpcyBzb2Z0d2FyZSBmb3IgYW55DQogICAgcHVycG9zZSB3aXRoIG9yIHdpdGhvdXQgZmVlIGlzIGhlcmVieSBncmFudGVkLg0KDQogICAgVEhFIFNPRlRXQVJFIElTIFBST1ZJREVEICJBUyBJUyIgQU5EIFRIRSBBVVRIT1IgRElTQ0xBSU1TIEFMTCBXQVJSQU5USUVTIFdJVEgNCiAgICBSRUdBUkQgVE8gVEhJUyBTT0ZUV0FSRSBJTkNMVURJTkcgQUxMIElNUExJRUQgV0FSUkFOVElFUyBPRiBNRVJDSEFOVEFCSUxJVFkNCiAgICBBTkQgRklUTkVTUy4gSU4gTk8gRVZFTlQgU0hBTEwgVEhFIEFVVEhPUiBCRSBMSUFCTEUgRk9SIEFOWSBTUEVDSUFMLCBESVJFQ1QsDQogICAgSU5ESVJFQ1QsIE9SIENPTlNFUVVFTlRJQUwgREFNQUdFUyBPUiBBTlkgREFNQUdFUyBXSEFUU09FVkVSIFJFU1VMVElORyBGUk9NDQogICAgTE9TUyBPRiBVU0UsIERBVEEgT1IgUFJPRklUUywgV0hFVEhFUiBJTiBBTiBBQ1RJT04gT0YgQ09OVFJBQ1QsIE5FR0xJR0VOQ0UgT1INCiAgICBPVEhFUiBUT1JUSU9VUyBBQ1RJT04sIEFSSVNJTkcgT1VUIE9GIE9SIElOIENPTk5FQ1RJT04gV0lUSCBUSEUgVVNFIE9SDQogICAgUEVSRk9STUFOQ0UgT0YgVEhJUyBTT0ZUV0FSRS4NCiAgICAqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKiAqLw0KDQogICAgZnVuY3Rpb24gX19hd2FpdGVyKHRoaXNBcmcsIF9hcmd1bWVudHMsIFAsIGdlbmVyYXRvcikgew0KICAgICAgICBmdW5jdGlvbiBhZG9wdCh2YWx1ZSkgeyByZXR1cm4gdmFsdWUgaW5zdGFuY2VvZiBQID8gdmFsdWUgOiBuZXcgUChmdW5jdGlvbiAocmVzb2x2ZSkgeyByZXNvbHZlKHZhbHVlKTsgfSk7IH0NCiAgICAgICAgcmV0dXJuIG5ldyAoUCB8fCAoUCA9IFByb21pc2UpKShmdW5jdGlvbiAocmVzb2x2ZSwgcmVqZWN0KSB7DQogICAgICAgICAgICBmdW5jdGlvbiBmdWxmaWxsZWQodmFsdWUpIHsgdHJ5IHsgc3RlcChnZW5lcmF0b3IubmV4dCh2YWx1ZSkpOyB9IGNhdGNoIChlKSB7IHJlamVjdChlKTsgfSB9DQogICAgICAgICAgICBmdW5jdGlvbiByZWplY3RlZCh2YWx1ZSkgeyB0cnkgeyBzdGVwKGdlbmVyYXRvclsidGhyb3ciXSh2YWx1ZSkpOyB9IGNhdGNoIChlKSB7IHJlamVjdChlKTsgfSB9DQogICAgICAgICAgICBmdW5jdGlvbiBzdGVwKHJlc3VsdCkgeyByZXN1bHQuZG9uZSA/IHJlc29sdmUocmVzdWx0LnZhbHVlKSA6IGFkb3B0KHJlc3VsdC52YWx1ZSkudGhlbihmdWxmaWxsZWQsIHJlamVjdGVkKTsgfQ0KICAgICAgICAgICAgc3RlcCgoZ2VuZXJhdG9yID0gZ2VuZXJhdG9yLmFwcGx5KHRoaXNBcmcsIF9hcmd1bWVudHMgfHwgW10pKS5uZXh0KCkpOw0KICAgICAgICB9KTsNCiAgICB9CgogICAgLyoKICAgICAqIGJhc2U2NC1hcnJheWJ1ZmZlciAxLjAuMSA8aHR0cHM6Ly9naXRodWIuY29tL25pa2xhc3ZoL2Jhc2U2NC1hcnJheWJ1ZmZlcj4KICAgICAqIENvcHlyaWdodCAoYykgMjAyMSBOaWtsYXMgdm9uIEhlcnR6ZW4gPGh0dHBzOi8vaGVydHplbi5jb20+CiAgICAgKiBSZWxlYXNlZCB1bmRlciBNSVQgTGljZW5zZQogICAgICovCiAgICB2YXIgY2hhcnMgPSAnQUJDREVGR0hJSktMTU5PUFFSU1RVVldYWVphYmNkZWZnaGlqa2xtbm9wcXJzdHV2d3h5ejAxMjM0NTY3ODkrLyc7CiAgICAvLyBVc2UgYSBsb29rdXAgdGFibGUgdG8gZmluZCB0aGUgaW5kZXguCiAgICB2YXIgbG9va3VwID0gdHlwZW9mIFVpbnQ4QXJyYXkgPT09ICd1bmRlZmluZWQnID8gW10gOiBuZXcgVWludDhBcnJheSgyNTYpOwogICAgZm9yICh2YXIgaSA9IDA7IGkgPCBjaGFycy5sZW5ndGg7IGkrKykgewogICAgICAgIGxvb2t1cFtjaGFycy5jaGFyQ29kZUF0KGkpXSA9IGk7CiAgICB9CiAgICB2YXIgZW5jb2RlID0gZnVuY3Rpb24gKGFycmF5YnVmZmVyKSB7CiAgICAgICAgdmFyIGJ5dGVzID0gbmV3IFVpbnQ4QXJyYXkoYXJyYXlidWZmZXIpLCBpLCBsZW4gPSBieXRlcy5sZW5ndGgsIGJhc2U2NCA9ICcnOwogICAgICAgIGZvciAoaSA9IDA7IGkgPCBsZW47IGkgKz0gMykgewogICAgICAgICAgICBiYXNlNjQgKz0gY2hhcnNbYnl0ZXNbaV0gPj4gMl07CiAgICAgICAgICAgIGJhc2U2NCArPSBjaGFyc1soKGJ5dGVzW2ldICYgMykgPDwgNCkgfCAoYnl0ZXNbaSArIDFdID4+IDQpXTsKICAgICAgICAgICAgYmFzZTY0ICs9IGNoYXJzWygoYnl0ZXNbaSArIDFdICYgMTUpIDw8IDIpIHwgKGJ5dGVzW2kgKyAyXSA+PiA2KV07CiAgICAgICAgICAgIGJhc2U2NCArPSBjaGFyc1tieXRlc1tpICsgMl0gJiA2M107CiAgICAgICAgfQogICAgICAgIGlmIChsZW4gJSAzID09PSAyKSB7CiAgICAgICAgICAgIGJhc2U2NCA9IGJhc2U2NC5zdWJzdHJpbmcoMCwgYmFzZTY0Lmxlbmd0aCAtIDEpICsgJz0nOwogICAgICAgIH0KICAgICAgICBlbHNlIGlmIChsZW4gJSAzID09PSAxKSB7CiAgICAgICAgICAgIGJhc2U2NCA9IGJhc2U2NC5zdWJzdHJpbmcoMCwgYmFzZTY0Lmxlbmd0aCAtIDIpICsgJz09JzsKICAgICAgICB9CiAgICAgICAgcmV0dXJuIGJhc2U2NDsKICAgIH07CgogICAgY29uc3QgbGFzdEJsb2JNYXAgPSBuZXcgTWFwKCk7DQogICAgY29uc3QgdHJhbnNwYXJlbnRCbG9iTWFwID0gbmV3IE1hcCgpOw0KICAgIGZ1bmN0aW9uIGdldFRyYW5zcGFyZW50QmxvYkZvcih3aWR0aCwgaGVpZ2h0LCBkYXRhVVJMT3B0aW9ucykgew0KICAgICAgICByZXR1cm4gX19hd2FpdGVyKHRoaXMsIHZvaWQgMCwgdm9pZCAwLCBmdW5jdGlvbiogKCkgew0KICAgICAgICAgICAgY29uc3QgaWQgPSBgJHt3aWR0aH0tJHtoZWlnaHR9YDsNCiAgICAgICAgICAgIGlmICgnT2Zmc2NyZWVuQ2FudmFzJyBpbiBnbG9iYWxUaGlzKSB7DQogICAgICAgICAgICAgICAgaWYgKHRyYW5zcGFyZW50QmxvYk1hcC5oYXMoaWQpKQ0KICAgICAgICAgICAgICAgICAgICByZXR1cm4gdHJhbnNwYXJlbnRCbG9iTWFwLmdldChpZCk7DQogICAgICAgICAgICAgICAgY29uc3Qgb2Zmc2NyZWVuID0gbmV3IE9mZnNjcmVlbkNhbnZhcyh3aWR0aCwgaGVpZ2h0KTsNCiAgICAgICAgICAgICAgICBvZmZzY3JlZW4uZ2V0Q29udGV4dCgnMmQnKTsNCiAgICAgICAgICAgICAgICBjb25zdCBibG9iID0geWllbGQgb2Zmc2NyZWVuLmNvbnZlcnRUb0Jsb2IoZGF0YVVSTE9wdGlvbnMpOw0KICAgICAgICAgICAgICAgIGNvbnN0IGFycmF5QnVmZmVyID0geWllbGQgYmxvYi5hcnJheUJ1ZmZlcigpOw0KICAgICAgICAgICAgICAgIGNvbnN0IGJhc2U2NCA9IGVuY29kZShhcnJheUJ1ZmZlcik7DQogICAgICAgICAgICAgICAgdHJhbnNwYXJlbnRCbG9iTWFwLnNldChpZCwgYmFzZTY0KTsNCiAgICAgICAgICAgICAgICByZXR1cm4gYmFzZTY0Ow0KICAgICAgICAgICAgfQ0KICAgICAgICAgICAgZWxzZSB7DQogICAgICAgICAgICAgICAgcmV0dXJuICcnOw0KICAgICAgICAgICAgfQ0KICAgICAgICB9KTsNCiAgICB9DQogICAgY29uc3Qgd29ya2VyID0gc2VsZjsNCiAgICB3b3JrZXIub25tZXNzYWdlID0gZnVuY3Rpb24gKGUpIHsNCiAgICAgICAgcmV0dXJuIF9fYXdhaXRlcih0aGlzLCB2b2lkIDAsIHZvaWQgMCwgZnVuY3Rpb24qICgpIHsNCiAgICAgICAgICAgIGlmICgnT2Zmc2NyZWVuQ2FudmFzJyBpbiBnbG9iYWxUaGlzKSB7DQogICAgICAgICAgICAgICAgY29uc3QgeyBpZCwgYml0bWFwLCB3aWR0aCwgaGVpZ2h0LCBkYXRhVVJMT3B0aW9ucyB9ID0gZS5kYXRhOw0KICAgICAgICAgICAgICAgIGNvbnN0IHRyYW5zcGFyZW50QmFzZTY0ID0gZ2V0VHJhbnNwYXJlbnRCbG9iRm9yKHdpZHRoLCBoZWlnaHQsIGRhdGFVUkxPcHRpb25zKTsNCiAgICAgICAgICAgICAgICBjb25zdCBvZmZzY3JlZW4gPSBuZXcgT2Zmc2NyZWVuQ2FudmFzKHdpZHRoLCBoZWlnaHQpOw0KICAgICAgICAgICAgICAgIGNvbnN0IGN0eCA9IG9mZnNjcmVlbi5nZXRDb250ZXh0KCcyZCcpOw0KICAgICAgICAgICAgICAgIGN0eC5kcmF3SW1hZ2UoYml0bWFwLCAwLCAwKTsNCiAgICAgICAgICAgICAgICBiaXRtYXAuY2xvc2UoKTsNCiAgICAgICAgICAgICAgICBjb25zdCBibG9iID0geWllbGQgb2Zmc2NyZWVuLmNvbnZlcnRUb0Jsb2IoZGF0YVVSTE9wdGlvbnMpOw0KICAgICAgICAgICAgICAgIGNvbnN0IHR5cGUgPSBibG9iLnR5cGU7DQogICAgICAgICAgICAgICAgY29uc3QgYXJyYXlCdWZmZXIgPSB5aWVsZCBibG9iLmFycmF5QnVmZmVyKCk7DQogICAgICAgICAgICAgICAgY29uc3QgYmFzZTY0ID0gZW5jb2RlKGFycmF5QnVmZmVyKTsNCiAgICAgICAgICAgICAgICBpZiAoIWxhc3RCbG9iTWFwLmhhcyhpZCkgJiYgKHlpZWxkIHRyYW5zcGFyZW50QmFzZTY0KSA9PT0gYmFzZTY0KSB7DQogICAgICAgICAgICAgICAgICAgIGxhc3RCbG9iTWFwLnNldChpZCwgYmFzZTY0KTsNCiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHdvcmtlci5wb3N0TWVzc2FnZSh7IGlkIH0pOw0KICAgICAgICAgICAgICAgIH0NCiAgICAgICAgICAgICAgICBpZiAobGFzdEJsb2JNYXAuZ2V0KGlkKSA9PT0gYmFzZTY0KQ0KICAgICAgICAgICAgICAgICAgICByZXR1cm4gd29ya2VyLnBvc3RNZXNzYWdlKHsgaWQgfSk7DQogICAgICAgICAgICAgICAgd29ya2VyLnBvc3RNZXNzYWdlKHsNCiAgICAgICAgICAgICAgICAgICAgaWQsDQogICAgICAgICAgICAgICAgICAgIHR5cGUsDQogICAgICAgICAgICAgICAgICAgIGJhc2U2NCwNCiAgICAgICAgICAgICAgICAgICAgd2lkdGgsDQogICAgICAgICAgICAgICAgICAgIGhlaWdodCwNCiAgICAgICAgICAgICAgICB9KTsNCiAgICAgICAgICAgICAgICBsYXN0QmxvYk1hcC5zZXQoaWQsIGJhc2U2NCk7DQogICAgICAgICAgICB9DQogICAgICAgICAgICBlbHNlIHsNCiAgICAgICAgICAgICAgICByZXR1cm4gd29ya2VyLnBvc3RNZXNzYWdlKHsgaWQ6IGUuZGF0YS5pZCB9KTsNCiAgICAgICAgICAgIH0NCiAgICAgICAgfSk7DQogICAgfTsKCn0pKCk7Cgo=`,null,!1),Ht=class{constructor(e){this.pendingCanvasMutations=new Map,this.rafStamps={latestId:0,invokeId:null},this.frozen=!1,this.locked=!1,this.processMutation=(e,t)=>{(this.rafStamps.invokeId&&this.rafStamps.latestId!==this.rafStamps.invokeId||!this.rafStamps.invokeId)&&(this.rafStamps.invokeId=this.rafStamps.latestId),this.pendingCanvasMutations.has(e)||this.pendingCanvasMutations.set(e,[]),this.pendingCanvasMutations.get(e).push(t)};let{sampling:t=`all`,win:n,blockClass:r,blockSelector:i,recordCanvas:a,dataURLOptions:o}=e;this.mutationCb=e.mutationCb,this.mirror=e.mirror,a&&t===`all`&&this.initCanvasMutationObserver(n,r,i),a&&typeof t==`number`&&this.initCanvasFPSObserver(t,n,r,i,{dataURLOptions:o})}reset(){this.pendingCanvasMutations.clear(),this.resetObservers&&this.resetObservers()}freeze(){this.frozen=!0}unfreeze(){this.frozen=!1}lock(){this.locked=!0}unlock(){this.locked=!1}initCanvasFPSObserver(e,t,n,r,i){let a=kt(t,n,r),o=new Map,s=new Vt;s.onmessage=e=>{let{id:t}=e.data;if(o.set(t,!1),!(`base64`in e.data))return;let{base64:n,type:r,width:i,height:a}=e.data;this.mutationCb({id:t,type:Ne[`2D`],commands:[{property:`clearRect`,args:[0,0,i,a]},{property:`drawImage`,args:[{rr_type:`ImageBitmap`,args:[{rr_type:`Blob`,data:[{rr_type:`ArrayBuffer`,base64:n}],type:r}]},0,0]}]})};let c=1e3/e,l=0,u,d=()=>{let e=[];return t.document.querySelectorAll(`canvas`).forEach(t=>{q(t,n,r,!0)||e.push(t)}),e},f=e=>{if(l&&e-l<c){u=requestAnimationFrame(f);return}l=e,d().forEach(e=>_t(this,void 0,void 0,function*(){let t=this.mirror.getId(e);if(o.get(t))return;if(o.set(t,!0),[`webgl`,`webgl2`].includes(e.__context)){let t=e.getContext(e.__context);t?.getContextAttributes()?.preserveDrawingBuffer===!1&&t?.clear(t.COLOR_BUFFER_BIT)}let n=yield createImageBitmap(e);s.postMessage({id:t,bitmap:n,width:e.width,height:e.height,dataURLOptions:i.dataURLOptions},[n])})),u=requestAnimationFrame(f)};u=requestAnimationFrame(f),this.resetObservers=()=>{a(),cancelAnimationFrame(u)}}initCanvasMutationObserver(e,t,n){this.startRAFTimestamping(),this.startPendingCanvasMutationFlusher();let r=kt(e,t,n),i=Ot(this.processMutation.bind(this),e,t,n),a=jt(this.processMutation.bind(this),e,t,n,this.mirror);this.resetObservers=()=>{r(),i(),a()}}startPendingCanvasMutationFlusher(){requestAnimationFrame(()=>this.flushPendingCanvasMutations())}startRAFTimestamping(){let e=t=>{this.rafStamps.latestId=t,requestAnimationFrame(e)};requestAnimationFrame(e)}flushPendingCanvasMutations(){this.pendingCanvasMutations.forEach((e,t)=>{let n=this.mirror.getId(t);this.flushPendingCanvasMutationFor(t,n)}),requestAnimationFrame(()=>this.flushPendingCanvasMutations())}flushPendingCanvasMutationFor(e,t){if(this.frozen||this.locked)return;let n=this.pendingCanvasMutations.get(e);if(!n||t===-1)return;let r=n.map(e=>gt(e,[`type`])),{type:i}=n[0];this.mutationCb({id:t,type:i,commands:r}),this.pendingCanvasMutations.delete(e)}},Ut=class{constructor(e){this.trackedLinkElements=new WeakSet,this.styleMirror=new je,this.mutationCb=e.mutationCb,this.adoptedStyleSheetCb=e.adoptedStyleSheetCb}attachLinkElement(e,t){`_cssText`in t.attributes&&this.mutationCb({adds:[],removes:[],texts:[],attributes:[{id:t.id,attributes:t.attributes}]}),this.trackLinkElement(e)}trackLinkElement(e){this.trackedLinkElements.has(e)||(this.trackedLinkElements.add(e),this.trackStylesheetInLinkElement(e))}adoptStyleSheets(e,t){if(e.length===0)return;let n={id:t,styleIds:[]},r=[];for(let t of e){let e;if(this.styleMirror.has(t))e=this.styleMirror.getId(t);else{e=this.styleMirror.add(t);let n=Array.from(t.rules||CSSRule);r.push({styleId:e,rules:n.map((e,t)=>({rule:S(e),index:t}))})}n.styleIds.push(e)}r.length>0&&(n.styles=r),this.adoptedStyleSheetCb(n)}reset(){this.styleMirror.reset(),this.trackedLinkElements=new WeakSet}trackStylesheetInLinkElement(e){}};function Z(e){return Object.assign(Object.assign({},e),{timestamp:Date.now()})}let Q,Wt,Gt,Kt=!1,$=T();function qt(e={}){let{emit:t,checkoutEveryNms:n,checkoutEveryNth:r,blockClass:i=`rr-block`,blockSelector:a=null,ignoreClass:o=`rr-ignore`,maskTextClass:s=`rr-mask`,maskTextSelector:c=null,inlineStylesheet:l=!0,maskAllInputs:u,maskInputOptions:d,slimDOMOptions:f,maskInputFn:p,maskTextFn:m,hooks:h,packFn:g,sampling:_={},dataURLOptions:v={},mousemoveWait:y,recordCanvas:b=!1,recordCrossOriginIframes:x=!1,userTriggeredOnInput:S=!1,collectFonts:C=!1,inlineImages:w=!1,plugins:T,keepIframeSrcFn:E=()=>!1,ignoreCSSAttributes:D=new Set([])}=e,O=x?window.parent===window:!0,k=!1;if(!O)try{window.parent.document,k=!1}catch{k=!0}if(O&&!t)throw Error(`emit function is required`);y!==void 0&&_.mousemove===void 0&&(_.mousemove=y),$.reset();let A=u===!0?{color:!0,date:!0,"datetime-local":!0,email:!0,month:!0,number:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0,textarea:!0,select:!0,password:!0}:d===void 0?{password:!0}:d,j=f===!0||f===`all`?{script:!0,comment:!0,headFavicon:!0,headWhitespace:!0,headMetaSocial:!0,headMetaRobots:!0,headMetaHttpEquiv:!0,headMetaVerification:!0,headMetaAuthorship:f===`all`,headMetaDescKeywords:f===`all`}:f||{};De();let M,N=0,P=e=>{for(let t of T||[])t.eventProcessor&&(e=t.eventProcessor(e));return g&&(e=g(e)),e};Q=(e,i)=>{if(Ue[0]?.isFrozen()&&e.type!==J.FullSnapshot&&!(e.type===J.IncrementalSnapshot&&e.data.source===Y.Mutation)&&Ue.forEach(e=>e.unfreeze()),O)t?.(P(e),i);else if(k){let t={type:`rrweb`,event:P(e),isCheckout:i};window.parent.postMessage(t,`*`)}if(e.type===J.FullSnapshot)M=e,N=0;else if(e.type===J.IncrementalSnapshot){if(e.data.source===Y.Mutation&&e.data.isAttachIframe)return;N++;let t=r&&N>=r,i=n&&e.timestamp-M.timestamp>n;(t||i)&&Wt(!0)}};let F=e=>{Q(Z({type:J.IncrementalSnapshot,data:Object.assign({source:Y.Mutation},e)}))},I=e=>Q(Z({type:J.IncrementalSnapshot,data:Object.assign({source:Y.Scroll},e)})),L=e=>Q(Z({type:J.IncrementalSnapshot,data:Object.assign({source:Y.CanvasMutation},e)})),R=new Ut({mutationCb:F,adoptedStyleSheetCb:e=>Q(Z({type:J.IncrementalSnapshot,data:Object.assign({source:Y.AdoptedStyleSheet},e)}))}),z=new mt({mirror:$,mutationCb:F,stylesheetManager:R,recordCrossOriginIframes:x,wrappedEmit:Q});for(let e of T||[])e.getMirror&&e.getMirror({nodeMirror:$,crossOriginIframeMirror:z.crossOriginIframeMirror,crossOriginIframeStyleMirror:z.crossOriginIframeStyleMirror});Gt=new Ht({recordCanvas:b,mutationCb:L,win:window,blockClass:i,blockSelector:a,mirror:$,sampling:_.canvas,dataURLOptions:v});let B=new ht({mutationCb:F,scrollCb:I,bypassOptions:{blockClass:i,blockSelector:a,maskTextClass:s,maskTextSelector:c,inlineStylesheet:l,maskInputOptions:A,dataURLOptions:v,maskTextFn:m,maskInputFn:p,recordCanvas:b,inlineImages:w,sampling:_,slimDOMOptions:j,iframeManager:z,stylesheetManager:R,canvasManager:Gt,keepIframeSrcFn:E},mirror:$});Wt=(e=!1)=>{Q(Z({type:J.Meta,data:{href:window.location.href,width:Se(),height:xe()}}),e),R.reset(),Ue.forEach(e=>e.lock());let t=he(document,{mirror:$,blockClass:i,blockSelector:a,maskTextClass:s,maskTextSelector:c,inlineStylesheet:l,maskAllInputs:A,maskTextFn:m,slimDOM:j,dataURLOptions:v,recordCanvas:b,inlineImages:w,onSerialize:e=>{Oe(e,$)&&z.addIframe(e),ke(e,$)&&R.trackLinkElement(e),Ae(e)&&B.addShadowRoot(e.shadowRoot,document)},onIframeLoad:(e,t)=>{z.attachIframe(e,t),B.observeAttachShadow(e)},onStylesheetLoad:(e,t)=>{R.attachLinkElement(e,t)},keepIframeSrcFn:E});if(!t)return console.warn(`Failed to snapshot the document`);Q(Z({type:J.FullSnapshot,data:{node:t,initialOffset:{left:window.pageXOffset===void 0?(document==null?void 0:document.documentElement.scrollLeft)||(document==null?void 0:document.body)?.parentElement?.scrollLeft||(document==null?void 0:document.body)?.scrollLeft||0:window.pageXOffset,top:window.pageYOffset===void 0?(document==null?void 0:document.documentElement.scrollTop)||(document==null?void 0:document.body)?.parentElement?.scrollTop||(document==null?void 0:document.body)?.scrollTop||0:window.pageYOffset}}})),Ue.forEach(e=>e.unlock()),document.adoptedStyleSheets&&document.adoptedStyleSheets.length>0&&R.adoptStyleSheets(document.adoptedStyleSheets,$.getId(document))};try{let e=[];e.push(K(`DOMContentLoaded`,()=>{Q(Z({type:J.DomContentLoaded,data:{}}))}));let t=e=>ft({mutationCb:F,mousemoveCb:(e,t)=>Q(Z({type:J.IncrementalSnapshot,data:{source:t,positions:e}})),mouseInteractionCb:e=>Q(Z({type:J.IncrementalSnapshot,data:Object.assign({source:Y.MouseInteraction},e)})),scrollCb:I,viewportResizeCb:e=>Q(Z({type:J.IncrementalSnapshot,data:Object.assign({source:Y.ViewportResize},e)})),inputCb:e=>Q(Z({type:J.IncrementalSnapshot,data:Object.assign({source:Y.Input},e)})),mediaInteractionCb:e=>Q(Z({type:J.IncrementalSnapshot,data:Object.assign({source:Y.MediaInteraction},e)})),styleSheetRuleCb:e=>Q(Z({type:J.IncrementalSnapshot,data:Object.assign({source:Y.StyleSheetRule},e)})),styleDeclarationCb:e=>Q(Z({type:J.IncrementalSnapshot,data:Object.assign({source:Y.StyleDeclaration},e)})),canvasMutationCb:L,fontCb:e=>Q(Z({type:J.IncrementalSnapshot,data:Object.assign({source:Y.Font},e)})),selectionCb:e=>{Q(Z({type:J.IncrementalSnapshot,data:Object.assign({source:Y.Selection},e)}))},blockClass:i,ignoreClass:o,maskTextClass:s,maskTextSelector:c,maskInputOptions:A,inlineStylesheet:l,sampling:_,recordCanvas:b,inlineImages:w,userTriggeredOnInput:S,collectFonts:C,doc:e,maskInputFn:p,maskTextFn:m,keepIframeSrcFn:E,blockSelector:a,slimDOMOptions:j,dataURLOptions:v,mirror:$,iframeManager:z,stylesheetManager:R,shadowDomManager:B,canvasManager:Gt,ignoreCSSAttributes:D,plugins:(T?.filter(e=>e.observer))?.map(e=>({observer:e.observer,options:e.options,callback:t=>Q(Z({type:J.Plugin,data:{plugin:e.name,payload:t}}))}))||[]},h);z.addLoadListener(n=>{e.push(t(n.contentDocument))});let n=()=>{Wt(),e.push(t(document)),Kt=!0};return document.readyState===`interactive`||document.readyState===`complete`?n():e.push(K(`load`,()=>{Q(Z({type:J.Load,data:{}})),n()},window)),()=>{e.forEach(e=>e()),Kt=!1}}catch(e){console.warn(e)}}qt.addCustomEvent=(e,t)=>{if(!Kt)throw Error(`please add custom event after start recording`);Q(Z({type:J.Custom,data:{tag:e,payload:t}}))},qt.freezePage=()=>{Ue.forEach(e=>e.freeze())},qt.takeFullSnapshot=e=>{if(!Kt)throw Error(`please take full snapshot after start recording`);Wt(e)},qt.mirror=$;function Jt(e){return typeof e!=`number`||!Number.isFinite(e)?100:Math.max(0,Math.min(100,e))}var Yt=class{endpoint;siteKey;debug;flushInterval;maxEvents;sampling;slimDOMOptions;maskAllInputs;maskInputOptions;blockClass;blockSelector;maskTextClass;maskTextSelector;checkoutEveryNms;checkoutEveryNth;samplingPercentage;recordConsole;events=[];flushTimer=null;stopRecording=void 0;started=!1;startTime=0;sequenceNumber=0;pendingBatches=[];isFlushing=!1;compressionSupported=!1;sessionSamplingSeed;minReplayLengthMs=3e3;constructor(e){this.siteKey=e.siteKey,this.endpoint=e.endpoint?.replace(/\/v1\/web$/,`/v1/replay`)??`https://metrics.faststats.dev/v1/replay`,this.debug=e.debug??!1,this.samplingPercentage=Jt(e.samplingPercentage),this.flushInterval=e.flushInterval??1e4,this.maxEvents=e.maxEvents??500,this.sampling=e.sampling??{mousemove:50,mouseInteraction:!0,scroll:150,media:800,input:`last`},this.slimDOMOptions=e.slimDOMOptions??{script:!0,comment:!0,headFavicon:!0,headWhitespace:!0,headMetaDescKeywords:!0,headMetaSocial:!0,headMetaRobots:!0,headMetaHttpEquiv:!0,headMetaAuthorship:!0},this.maskAllInputs=e.maskAllInputs??!0,this.maskInputOptions=e.maskInputOptions??{password:!0,email:!0,tel:!0},this.blockClass=e.blockClass,this.blockSelector=e.blockSelector,this.maskTextClass=e.maskTextClass,this.maskTextSelector=e.maskTextSelector,this.checkoutEveryNms=e.checkoutEveryNms??6e4,this.checkoutEveryNth=e.checkoutEveryNth,this.recordConsole=e.recordConsole??!0,this.sessionSamplingSeed=Math.random()*100,typeof window<`u`&&(this.compressionSupported=`CompressionStream`in window)}start(){if(this.started||typeof window>`u`)return;if(window.__FA_isTrackingDisabled?.()){this.debug&&console.log(`[Replay] Tracking disabled via localStorage`);return}if(this.samplingPercentage<100&&this.sessionSamplingSeed>=this.samplingPercentage)return;this.started=!0,this.startTime=Date.now(),this.debug&&console.log(`[Replay] Recording started`);let e={emit:(e,t)=>this.handleEvent(e,t),sampling:this.sampling,slimDOMOptions:this.slimDOMOptions,maskAllInputs:this.maskAllInputs,checkoutEveryNms:this.checkoutEveryNms};this.maskInputOptions&&(e.maskInputOptions=this.maskInputOptions),this.blockClass&&(e.blockClass=this.blockClass),this.blockSelector&&(e.blockSelector=this.blockSelector),this.maskTextClass&&(e.maskTextClass=this.maskTextClass),this.maskTextSelector&&(e.maskTextSelector=this.maskTextSelector),this.checkoutEveryNth&&(e.checkoutEveryNth=this.checkoutEveryNth),this.recordConsole&&(e.plugins=[h()]),this.stopRecording=qt(e),this.flushTimer=setInterval(()=>{this.scheduleFlush()},this.flushInterval),window.addEventListener(`beforeunload`,this.handleUnload),window.addEventListener(`pagehide`,this.handleUnload),document.addEventListener(`visibilitychange`,this.handleVisibilityChange)}stop(){if(!this.started)return;this.started=!1,this.debug&&console.log(`[Replay] Recording stopped`),this.stopRecording?.(),this.stopRecording=void 0,this.flushTimer&&=(clearInterval(this.flushTimer),null),window.removeEventListener(`beforeunload`,this.handleUnload),window.removeEventListener(`pagehide`,this.handleUnload),document.removeEventListener(`visibilitychange`,this.handleVisibilityChange);let e=Date.now()-this.startTime;if(e<this.minReplayLengthMs){this.events=[],this.debug&&console.log(`[Replay] Session too short (${e}ms), discarding events`);return}this.flush()}handleEvent(e,t){this.events.push(e),(t||this.events.length>=this.maxEvents)&&this.scheduleFlush()}scheduleFlush(){this.isFlushing||this.events.length===0||(typeof window<`u`&&`requestIdleCallback`in window?window.requestIdleCallback(()=>this.flush(),{timeout:2e3}):setTimeout(()=>this.flush(),0))}handleUnload=()=>{this.flush()};handleVisibilityChange=()=>{document.visibilityState===`hidden`?(this.flushTimer&&=(clearInterval(this.flushTimer),null),this.flush()):document.visibilityState===`visible`&&this.started&&(this.flushTimer||=setInterval(()=>{this.scheduleFlush()},this.flushInterval))};async flush(){if(this.events.length===0){this.processPendingBatches();return}let e=Date.now()-this.startTime;if(e<this.minReplayLengthMs){this.debug&&console.log(`[Replay] Too short (${e}ms), skipping`),this.processPendingBatches();return}if(this.isFlushing)return;this.isFlushing=!0;let t=this.events;this.events=[];let n=window.__FA_getAnonymousId?.(),r={token:this.siteKey,sessionId:window.__FA_getSessionId?.(),...n?{identifier:n}:{},sequence:this.sequenceNumber++,timestamp:Date.now(),url:window.location.href,events:t};this.debug&&console.log(`[Replay] Sending ${t.length} events (seq: ${r.sequence})`);try{let e,t=!1;if(this.compressionSupported)try{e=await this.compress(JSON.stringify(r)),t=!0}catch{this.debug&&console.warn(`[Replay] Compression failed, using uncompressed`),e=new Blob([JSON.stringify(r)],{type:`application/json`})}else e=new Blob([JSON.stringify(r)],{type:`application/json`});await this.send(e,t)||this.pendingBatches.push({batch:r,isCompressed:t,retries:0})}catch(e){this.debug&&console.warn(`[Replay] Flush error:`,e),this.pendingBatches.push({batch:r,isCompressed:!1,retries:0})}finally{this.isFlushing=!1,this.processPendingBatches()}}async processPendingBatches(){if(this.pendingBatches.length===0)return;let e=this.pendingBatches.shift();if(e){if(e.retries>=3){this.debug&&console.warn(`[Replay] Max retries reached, dropping batch ${e.batch.sequence}`),this.processPendingBatches();return}e.retries++;try{let t;if(e.isCompressed&&this.compressionSupported)try{t=await this.compress(JSON.stringify(e.batch))}catch{t=new Blob([JSON.stringify(e.batch)],{type:`application/json`}),e.isCompressed=!1}else t=new Blob([JSON.stringify(e.batch)],{type:`application/json`});await this.send(t,e.isCompressed)?this.processPendingBatches():(this.pendingBatches.push(e),setTimeout(()=>this.processPendingBatches(),1e3*e.retries))}catch{this.debug&&console.warn(`[Replay] Retry ${e.retries} failed`),this.pendingBatches.push(e),setTimeout(()=>this.processPendingBatches(),1e3*e.retries)}}}async compress(e){if(!this.compressionSupported)throw Error(`Compression not supported`);let t=new TextEncoder().encode(e),n=new CompressionStream(`gzip`),r=n.writable.getWriter();r.write(t),r.close();let i=[],a=n.readable.getReader();for(;;){let{done:e,value:t}=await a.read();if(e)break;t&&i.push(t)}let o=i.reduce((e,t)=>e+t.length,0),s=new Uint8Array(o),c=0;for(let e of i)s.set(e,c),c+=e.length;if(this.debug){let e=(s.length/t.length*100).toFixed(1);console.log(`[Replay] Compressed: ${t.length} → ${s.length} bytes (${e}%)`)}return new Blob([s],{type:`application/octet-stream`})}async send(e,t){let n=t?`${this.endpoint}?encoding=gzip`:this.endpoint,r=(e.size/1024).toFixed(1);return window.__FA_sendData?.({url:n,data:e,contentType:t?`application/octet-stream`:`application/json`,headers:t?{"Content-Encoding":`gzip`}:void 0,debug:this.debug,debugPrefix:`[Replay] ${r}KB`})??Promise.resolve(!1)}getSessionId(){return window.__FA_getSessionId?.()}};return typeof window<`u`&&(window.__FA_ReplayTracker=Yt),Yt})();
|