@mrrocket/sdk 0.2.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +16 -0
- package/README.md +142 -2
- package/dist/batch.d.ts +33 -0
- package/dist/batch.js +50 -0
- package/dist/batch.js.map +1 -0
- package/dist/browser/mrrocket-replay.js +78 -0
- package/dist/browser/mrrocket.js +1 -0
- package/dist/browser.d.ts +1 -1
- package/dist/browser.js +3 -1
- package/dist/browser.js.map +1 -1
- package/dist/client.d.ts +23 -3
- package/dist/client.js +44 -83
- package/dist/client.js.map +1 -1
- package/dist/context.d.ts +2 -0
- package/dist/context.js.map +1 -1
- package/dist/core.d.ts +94 -1
- package/dist/core.js +88 -4
- package/dist/core.js.map +1 -1
- package/dist/errors.d.ts +35 -0
- package/dist/errors.js +83 -0
- package/dist/errors.js.map +1 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.js +8 -0
- package/dist/index.js.map +1 -1
- package/dist/react-native/index.d.cts +259 -0
- package/dist/react-native/index.d.ts +259 -0
- package/dist/react-native/index.js +922 -0
- package/dist/react-native/index.js.map +1 -0
- package/dist/react-native/package.json +3 -0
- package/dist/referral.d.ts +6 -0
- package/dist/referral.js +7 -3
- package/dist/referral.js.map +1 -1
- package/dist/server.d.ts +13 -1
- package/dist/server.js +8 -1
- package/dist/server.js.map +1 -1
- package/dist/styles.d.ts +1 -1
- package/dist/styles.js +2 -2
- package/dist/styles.js.map +1 -1
- package/dist/web-state.d.ts +36 -0
- package/dist/web-state.js +64 -0
- package/dist/web-state.js.map +1 -0
- package/package.json +56 -6
- package/react-native/package.json +7 -0
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,22 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this package. It follows semantic versioning; before 1.0 a minor version may change an API.
|
|
4
4
|
|
|
5
|
+
## 0.4.0
|
|
6
|
+
|
|
7
|
+
- **React Native and Expo:** new entry `@mrrocket/sdk/react-native` (one CommonJS file for Metro, no DOM, no `"use client"`, no rrweb). `MRRocketProvider`, `useMRRocket`, `useFlag`, `useFlagVariant`, `useVariant`, `createMRRocket` / `getMRRocket` outside React; `track`, `identify`, `reset`, `screen`, `setConsent`, `captureError`, `flush`. Screen views through `useExpoRouterTracking()` (Expo Router) or `useNavigationTracking()` (React Navigation `onStateChange`). Lifecycle events `$app_open` (with `cold`) and `$app_background`; a new session after 30 minutes in the background. Events are batched, sent every 10 s and when the app goes to the background, and kept on the device while offline (AsyncStorage when installed, else memory; at most 1,000, oldest dropped; retries with backoff). Consent `"anonymous"` (default: no id stored), `"persistent"` (a random install id stored on the device) or `"off"` (nothing sent, stored data deleted). Every event carries the app and device (`platform`, `appVersion`, `build`, `osVersion`, `deviceModel`, `deviceType`, `locale`) from `expo-application`, `expo-device` and `expo-localization` when installed. Uncaught JavaScript errors (through `ErrorUtils`, the app's own handler still runs) and `captureError` go to Build › Errors with the app version as release. The config for flags and experiments is cached, so a cold start shows the same variant as the last run. Install attribution: UTM and referral parameters of the deep link that opened the app the first time, sent once with `$install`; no IDFA, no MMP.
|
|
8
|
+
- **Script tag** for websites without npm (Webflow, Framer, WordPress, Shopify, plain HTML): `<script async src="https://app.mrrocket.dev/sdk.js" data-key="mrr_pub_…"></script>`, built from the same sources into `dist/browser/mrrocket.js` (about 8 KB gzip) and served by MRRocket at `/sdk.js`. It does what the Next.js provider does on the client: page views including History API navigation, `data-ck-goal` clicks, heatmap clicks and scroll depth, UTM and referrer, affiliate referrals, error tracking, feature flags, experiments on texts marked `data-ck-text`, and session recordings (the recorder, `sdk-replay.js`, about 26 KB gzip, loads only when a visit records). `window.mrrocket` takes `track`, `identify`, `reset`, `captureError`, `setConsent`, `getFlag`, `getFlagVariant`, `getVariant`, `ready`; calls made before it loaded wait in a queue stub. Settings as data attributes: `data-api-host`, `data-consent`, `data-replay`, `data-respect-dnt`, `data-heatmaps`, `data-errors`, `data-release`, `data-attribution`, `data-referral-param`.
|
|
9
|
+
- Shared code: batching (`batch.ts`) and the browser's visitor and session state (`web-state.ts`) moved out of the Next.js provider so the script tag uses the same code. The Next.js entry behaves as in 0.3.0.
|
|
10
|
+
- Peers: `next` and `react-dom` are optional now (an app needs neither); `react-native`, `expo-router`, `expo-device`, `expo-application`, `expo-localization` and `@react-native-async-storage/async-storage` are optional peers. `react` from 18.
|
|
11
|
+
- Event batches carry `sdk.platform` ("web", "ios" or "android"); MRRocket stores an app's device context with each event.
|
|
12
|
+
- Not in this version (coming later): session recordings and heatmaps in apps, the feedback and survey UI in apps, native modules (store install referrer, SKAdNetwork). `<Text>` and `<Experiment>` stay Next.js-only; the script tag swaps texts through `data-ck-text`.
|
|
13
|
+
|
|
14
|
+
## 0.3.0
|
|
15
|
+
|
|
16
|
+
- **Error tracking** for MRRocket › Build › Errors, on by default (`errors` prop): uncaught errors and unhandled promise rejections, with the page URL and the last 20 pages and clicks, go to `POST /api/sdk/errors` in batches every 2 s (`sendBeacon` on page hide), under the normal analytics consent and never from a preview. The same error once per page load, at most 20 per page load. `useCockpit().captureError(error)` reports one you caught; the `release` prop names your release. Independent of session recordings.
|
|
17
|
+
- **Feature flags** from MRRocket › Build › Feature flags: `useFlag(key)` and `useFlagVariant(key)` in the browser, `getFlag` and `getFlagVariant` on the server (`/next/server`). The config carries the Production flags; each is evaluated in the SDK from the person's `identify()` properties ("Email", "Plan" …, `@domain` matches an address, cohorts never match in the browser) and a stable bucket per flag and person. New exports `evaluateFlag`, `SDK_VERSION`, types `FlagConfig`, `FlagCondition`, `FlagConditionSet`, `FlagPerson`, `ErrorReport`.
|
|
18
|
+
- Event batches carry `sdk: { v, errors }`, so MRRocket can say which SDK a site runs and whether it reports errors.
|
|
19
|
+
- Fix: unselected stars of a 1–5 survey question are gray again (a button reset made them take the text color).
|
|
20
|
+
|
|
5
21
|
## 0.2.0
|
|
6
22
|
|
|
7
23
|
- **Session recordings** (rrweb 2.1.6 via `@rrweb/record`, pinned): recorded only with the visitor's own replay consent, separate from analytics and off by default: new `replay` prop and `setConsent({ replay })` (`setConsent` now also takes `{ analytics?, replay? }`; `useCockpit()` returns `replay`). The recorder is a dynamic import, loaded only when a visit records (about 26 KB gzip); pages without recording load about 1.9 KB more than 0.1.0.
|
package/README.md
CHANGED
|
@@ -1,8 +1,16 @@
|
|
|
1
1
|
# @mrrocket/sdk
|
|
2
2
|
|
|
3
|
-
The MRRocket SDK
|
|
3
|
+
The MRRocket SDK, one package with three ways in:
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
| Where | Import | Section |
|
|
6
|
+
| --- | --- | --- |
|
|
7
|
+
| Next.js (App Router) | `@mrrocket/sdk/next` | 1 to 12 |
|
|
8
|
+
| Any website without npm (Webflow, Framer, WordPress, Shopify, plain HTML) | `<script src="…/sdk.js">` | 13 |
|
|
9
|
+
| React Native and Expo apps | `@mrrocket/sdk/react-native` | 14 |
|
|
10
|
+
|
|
11
|
+
One provider in your layout (or one script tag) gives MRRocket page views, your events, A/B tests, feature flags and errors that the agents can run and read. MRRocket shows every variant of your real pages, because the SDK can render any variant on request.
|
|
12
|
+
|
|
13
|
+
Status: 0.4.0, MIT licensed, compiled to ESM JavaScript with type declarations (no `transpilePackages`); the React Native entry is CommonJS for Metro. Works with Next.js 15 and 16, React 18 and 19, on Node and on Cloudflare Workers (OpenNext), and with React Native 0.72+ / Expo. The source lives in the MRRocket repo (`prototype/web/packages/cockpit-next`).
|
|
6
14
|
|
|
7
15
|
## Install
|
|
8
16
|
|
|
@@ -232,6 +240,136 @@ The recorder (about 26 KB gzip with rrweb) loads only when a visit records: prod
|
|
|
232
240
|
|
|
233
241
|
MRRocket keeps recordings 30 days by default (at most 90), in the EU. Add the recording paragraph to your privacy policy; Sessions' "Copy for AI" prompt adds the banner choice, the wiring and the paragraph for you.
|
|
234
242
|
|
|
243
|
+
## 13. Script tag (any website)
|
|
244
|
+
|
|
245
|
+
For sites without npm. Paste into the `<head>` of every page (MRRocket › Settings › Products › Tracking shows it with your key filled in):
|
|
246
|
+
|
|
247
|
+
```html
|
|
248
|
+
<script async src="https://app.mrrocket.dev/sdk.js" data-key="mrr_pub_…"></script>
|
|
249
|
+
```
|
|
250
|
+
|
|
251
|
+
Where it goes: Webflow: Site settings › Custom code › Head. Framer: Site settings › General › Custom code. WordPress: the theme's header or a header-code plugin. Shopify: `theme.liquid`, before `</head>`.
|
|
252
|
+
|
|
253
|
+
On its own it sends page views (also client-side navigation through the History API), `data-ck-goal` clicks (2), heatmap clicks and scroll depth (11), UTM and referrer, affiliate referrals (10), uncaught errors, and loads flags and experiments. Calls go to `window.mrrocket`:
|
|
254
|
+
|
|
255
|
+
```js
|
|
256
|
+
mrrocket.track("signup", { plan: "team" });
|
|
257
|
+
mrrocket.identify(user.id, { email: user.email, plan: "pro" });
|
|
258
|
+
mrrocket.reset(); // on sign-out
|
|
259
|
+
mrrocket.captureError(error);
|
|
260
|
+
mrrocket.setConsent("cookies"); // "cookieless" | "cookies" | "off" | { analytics?, replay? }
|
|
261
|
+
mrrocket.ready(function (m) {
|
|
262
|
+
if (m.getFlag("new-checkout")) showNewCheckout();
|
|
263
|
+
var v = m.getVariant("pricing-hero"); // records the exposure
|
|
264
|
+
});
|
|
265
|
+
```
|
|
266
|
+
|
|
267
|
+
To call it before the file has loaded, put this stub above the script tag; the calls wait in a queue and run once it has:
|
|
268
|
+
|
|
269
|
+
```html
|
|
270
|
+
<script>!function(w,m){w[m]=w[m]||{q:[]};"track identify reset captureError setConsent ready".split(" ").forEach(function(k){w[m][k]=w[m][k]||function(){w[m].q.push([k,arguments])}})}(window,"mrrocket");</script>
|
|
271
|
+
```
|
|
272
|
+
|
|
273
|
+
Settings are data attributes on the script tag:
|
|
274
|
+
|
|
275
|
+
| Attribute | What | Default |
|
|
276
|
+
| --- | --- | --- |
|
|
277
|
+
| `data-key` | The product's public key | required |
|
|
278
|
+
| `data-api-host` | Where MRRocket runs | where `sdk.js` came from |
|
|
279
|
+
| `data-consent` | `cookieless`, `cookies` or `off` (see Privacy) | `cookieless` |
|
|
280
|
+
| `data-replay` | `true` once the visitor agreed to session recordings | off |
|
|
281
|
+
| `data-respect-dnt` | Send nothing under Do Not Track or GPC | off |
|
|
282
|
+
| `data-heatmaps` / `data-errors` | `false` turns them off | on |
|
|
283
|
+
| `data-release` | Your release, for Build › Errors | none |
|
|
284
|
+
| `data-attribution` / `data-referral-param` | Affiliate referrals: `consent`, `always`, `off`; the direct-link parameter | `consent`, `ref` |
|
|
285
|
+
|
|
286
|
+
**Experiments on texts:** mark an element `data-ck-text="hero-title"` and MRRocket's variant texts replace its text; the original text is the control. `<Text>` and `<Experiment>` (React components) are Next.js-only.
|
|
287
|
+
|
|
288
|
+
**Session recordings:** when the product records and the visitor's replay consent is given (`data-replay="true"` or `setConsent({ replay: true })`), the recorder loads from `sdk-replay.js` (about 26 KB gzip) next to `sdk.js`; pages that do not record never load it. Same privacy defaults as 12.
|
|
289
|
+
|
|
290
|
+
`sdk.js` is about 8 KB gzip. MRRocket serves it with open CORS and a short cache (browsers 5 minutes, CDN 1 hour), so a new release reaches every site within the hour.
|
|
291
|
+
|
|
292
|
+
## 14. React Native and Expo
|
|
293
|
+
|
|
294
|
+
```bash
|
|
295
|
+
npx expo install @mrrocket/sdk @react-native-async-storage/async-storage expo-device expo-application expo-localization
|
|
296
|
+
```
|
|
297
|
+
|
|
298
|
+
Only `@mrrocket/sdk` is required. AsyncStorage keeps unsent events and the cached config across launches (without it: memory only); the three `expo-*` modules add app version, OS, device and locale. A bare React Native app installs `@mrrocket/sdk` and AsyncStorage and runs `pod install`. No native module of its own: Expo Go works.
|
|
299
|
+
|
|
300
|
+
```tsx
|
|
301
|
+
// app/_layout.tsx (Expo Router)
|
|
302
|
+
import { Stack } from "expo-router";
|
|
303
|
+
import { MRRocketProvider, useExpoRouterTracking } from "@mrrocket/sdk/react-native";
|
|
304
|
+
|
|
305
|
+
function Screens() {
|
|
306
|
+
useExpoRouterTracking(); // one $screen per path
|
|
307
|
+
return <Stack />;
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
export default function RootLayout() {
|
|
311
|
+
return (
|
|
312
|
+
<MRRocketProvider apiKey="mrr_pub_…">
|
|
313
|
+
<Screens />
|
|
314
|
+
</MRRocketProvider>
|
|
315
|
+
);
|
|
316
|
+
}
|
|
317
|
+
```
|
|
318
|
+
|
|
319
|
+
React Navigation instead of Expo Router:
|
|
320
|
+
|
|
321
|
+
```tsx
|
|
322
|
+
const ref = useNavigationContainerRef();
|
|
323
|
+
const onStateChange = useNavigationTracking();
|
|
324
|
+
<NavigationContainer ref={ref} onReady={() => onStateChange(ref.getRootState())} onStateChange={onStateChange}>
|
|
325
|
+
```
|
|
326
|
+
|
|
327
|
+
Use the same public key as the product's website. In components:
|
|
328
|
+
|
|
329
|
+
```tsx
|
|
330
|
+
const { track, identify, reset, screen, setConsent, captureError, flush, ready } = useMRRocket();
|
|
331
|
+
const newCheckout = useFlag("new-checkout"); // false until the config is known
|
|
332
|
+
const plan = useFlagVariant("plan-picker"); // string | null
|
|
333
|
+
const variant = useVariant("paywall"); // "control" until known; records the exposure once per screen
|
|
334
|
+
```
|
|
335
|
+
|
|
336
|
+
Outside React (a store, a background task): `createMRRocket({ apiKey })` returns the one client the provider would use; `getMRRocket()` returns the running one.
|
|
337
|
+
|
|
338
|
+
| Prop | What | Default |
|
|
339
|
+
| --- | --- | --- |
|
|
340
|
+
| `apiKey` | The product's public key | required |
|
|
341
|
+
| `host` | Where MRRocket runs | `https://app.mrrocket.dev` |
|
|
342
|
+
| `consent` | `"anonymous"`, `"persistent"` or `"off"` (below) | `"anonymous"` |
|
|
343
|
+
| `errors` | Uncaught JS errors and `captureError` to Build › Errors | true |
|
|
344
|
+
| `release` | Your release for Build › Errors | app version and build, like `1.4.0 (42)` |
|
|
345
|
+
| `lifecycle` | `$app_open` and `$app_background` | true |
|
|
346
|
+
| `attribution` | UTM and referral parameters of the first deep link, sent with `$install` | true |
|
|
347
|
+
| `flushIntervalMs` | How often the queue is sent while open | 10 000 |
|
|
348
|
+
| `maxQueue` | Events kept on the device while offline; the oldest go first | 1,000 |
|
|
349
|
+
| `storage` | AsyncStorage-shaped storage (MMKV, SecureStore), or `null` for memory | AsyncStorage when installed |
|
|
350
|
+
| `debug` | Log to the console | false |
|
|
351
|
+
|
|
352
|
+
What it does:
|
|
353
|
+
|
|
354
|
+
- **Lifecycle:** `$app_open` (`cold: true` on a fresh start) and `$app_background`. A session ends after 30 minutes in the background.
|
|
355
|
+
- **Queue:** events are batched, sent every 10 s and when the app goes to the background, and kept on the device while offline, then retried with backoff.
|
|
356
|
+
- **Device:** every event carries `app: { platform, appVersion, build, osVersion, deviceModel, deviceType, locale }`. MRRocket shows the app as browser "App" with OS iOS or Android.
|
|
357
|
+
- **Errors:** a global handler through `ErrorUtils` (your own handler still runs, so the red box still shows in development); `captureError(error)` for caught ones; the same error once per launch, at most 20.
|
|
358
|
+
- **Flags and experiments:** from the same config as the website, cached on the device, so a cold start shows the variant of the last run before the network answers.
|
|
359
|
+
- **Install attribution:** on the first open, the UTM and `ref` parameters of the deep link that opened the app go with `$install`. No IDFA and no ad network SDK, so no App Tracking Transparency prompt is needed.
|
|
360
|
+
|
|
361
|
+
Consent:
|
|
362
|
+
|
|
363
|
+
| `consent` | Stored on the device | Sent |
|
|
364
|
+
| --- | --- | --- |
|
|
365
|
+
| `"anonymous"` (default) | Unsent events and the config, no id | Events without an id until `identify()`; flags use a random id for this launch |
|
|
366
|
+
| `"persistent"` | A random install id (gone with the app), plus the above | Events with the install id |
|
|
367
|
+
| `"off"` | Nothing; what the SDK stored is deleted | Nothing |
|
|
368
|
+
|
|
369
|
+
The SDK does not remember the choice: pass it on every start from your consent screen's stored answer, or call `setConsent()`.
|
|
370
|
+
|
|
371
|
+
Not in this version (coming later): session recordings and heatmaps, the feedback and survey UI, store install referrer and SKAdNetwork.
|
|
372
|
+
|
|
235
373
|
## Privacy and consent
|
|
236
374
|
|
|
237
375
|
```tsx
|
|
@@ -274,7 +412,9 @@ MRRocket keeps recordings 30 days by default (at most 90), in the EU. Add the re
|
|
|
274
412
|
utm_term?: string;
|
|
275
413
|
utm_content?: string;
|
|
276
414
|
screen?: { w: number; h: number };
|
|
415
|
+
app?: { platform: string; appVersion?: string; build?: string; osVersion?: string; deviceModel?: string; deviceType?: string; locale?: string }; // React Native only
|
|
277
416
|
}[];
|
|
417
|
+
sdk?: { v: string; errors: boolean; platform: "web" | "ios" | "android" };
|
|
278
418
|
}
|
|
279
419
|
```
|
|
280
420
|
|
package/dist/batch.d.ts
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* How events go over the wire to `POST /api/sdk/events`, shared by every runtime (Next.js, the script tag, React
|
|
3
|
+
* Native): request bodies of at most 100 events each, under the server's 64 KB. No React, no browser APIs, no
|
|
4
|
+
* TextEncoder (Hermes on older React Native lacks it), so it runs anywhere.
|
|
5
|
+
*/
|
|
6
|
+
import type { CockpitEvent } from "./core.js";
|
|
7
|
+
/** The server takes at most 100 events and 64 KB per request; stay a little under the size. */
|
|
8
|
+
export declare const MAX_BATCH = 100;
|
|
9
|
+
export declare const MAX_BYTES = 60000;
|
|
10
|
+
/** What a batch says about the SDK that sent it (Build › Errors and Feature flags show it). */
|
|
11
|
+
export interface SdkInfo {
|
|
12
|
+
v: string;
|
|
13
|
+
errors: boolean;
|
|
14
|
+
/** "web" (script tag), "ios" or "android" (React Native). Missing from the Next.js provider. */
|
|
15
|
+
platform?: string;
|
|
16
|
+
}
|
|
17
|
+
/** UTF-8 length of a string, the way TextEncoder counts it (a lone surrogate becomes U+FFFD, three bytes). */
|
|
18
|
+
export declare const byteLength: (s: string) => number;
|
|
19
|
+
/** One request: its body and the events in it (so a client can keep the ones that did not arrive). */
|
|
20
|
+
export interface BatchRequest<E> {
|
|
21
|
+
body: string;
|
|
22
|
+
events: E[];
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Splits events into request bodies of at most 100 events each, under the size limit. An event too large on its own is
|
|
26
|
+
* dropped (it is in no request).
|
|
27
|
+
*/
|
|
28
|
+
export declare const batchRequests: <E extends CockpitEvent>(key: string, events: E[], sdk: SdkInfo) => BatchRequest<E>[];
|
|
29
|
+
/**
|
|
30
|
+
* Request bodies of at most 100 events each, under the size limit. An event too large on its own is dropped. `sdk` tells
|
|
31
|
+
* MRRocket which SDK the site runs and whether it reports errors (Build › Errors and Feature flags show it).
|
|
32
|
+
*/
|
|
33
|
+
export declare const bodies: (key: string, events: CockpitEvent[], sdk: SdkInfo) => string[];
|
package/dist/batch.js
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
// src/batch.ts
|
|
2
|
+
var MAX_BATCH = 100;
|
|
3
|
+
var MAX_BYTES = 6e4;
|
|
4
|
+
var byteLength = (s) => {
|
|
5
|
+
let n = 0;
|
|
6
|
+
for (let i = 0; i < s.length; i++) {
|
|
7
|
+
const c = s.charCodeAt(i);
|
|
8
|
+
if (c < 128) n += 1;
|
|
9
|
+
else if (c < 2048) n += 2;
|
|
10
|
+
else if (c >= 55296 && c <= 56319 && i + 1 < s.length && (s.charCodeAt(i + 1) & 64512) === 56320) {
|
|
11
|
+
n += 4;
|
|
12
|
+
i++;
|
|
13
|
+
} else n += 3;
|
|
14
|
+
}
|
|
15
|
+
return n;
|
|
16
|
+
};
|
|
17
|
+
var batchRequests = (key, events, sdk) => {
|
|
18
|
+
const head = `{"key":${JSON.stringify(key)},"sdk":${JSON.stringify(sdk)},"events":[`;
|
|
19
|
+
const empty = byteLength(head) + 2;
|
|
20
|
+
const out = [];
|
|
21
|
+
let chunk = [];
|
|
22
|
+
let items = [];
|
|
23
|
+
let size = empty;
|
|
24
|
+
const close = () => {
|
|
25
|
+
if (chunk.length) out.push({ body: `${head}${chunk.join(",")}]}`, events: items });
|
|
26
|
+
chunk = [];
|
|
27
|
+
items = [];
|
|
28
|
+
size = empty;
|
|
29
|
+
};
|
|
30
|
+
for (const event of events) {
|
|
31
|
+
const json = JSON.stringify(event);
|
|
32
|
+
const n = byteLength(json) + 1;
|
|
33
|
+
if (empty + n > MAX_BYTES) continue;
|
|
34
|
+
if (chunk.length === MAX_BATCH || size + n > MAX_BYTES) close();
|
|
35
|
+
chunk.push(json);
|
|
36
|
+
items.push(event);
|
|
37
|
+
size += n;
|
|
38
|
+
}
|
|
39
|
+
close();
|
|
40
|
+
return out;
|
|
41
|
+
};
|
|
42
|
+
var bodies = (key, events, sdk) => batchRequests(key, events, sdk).map((r) => r.body);
|
|
43
|
+
export {
|
|
44
|
+
MAX_BATCH,
|
|
45
|
+
MAX_BYTES,
|
|
46
|
+
batchRequests,
|
|
47
|
+
bodies,
|
|
48
|
+
byteLength
|
|
49
|
+
};
|
|
50
|
+
//# sourceMappingURL=batch.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/batch.ts"],"sourcesContent":["/**\n * How events go over the wire to `POST /api/sdk/events`, shared by every runtime (Next.js, the script tag, React\n * Native): request bodies of at most 100 events each, under the server's 64 KB. No React, no browser APIs, no\n * TextEncoder (Hermes on older React Native lacks it), so it runs anywhere.\n */\nimport type { CockpitEvent } from \"./core\";\n\n/** The server takes at most 100 events and 64 KB per request; stay a little under the size. */\nexport const MAX_BATCH = 100;\nexport const MAX_BYTES = 60_000;\n\n/** What a batch says about the SDK that sent it (Build › Errors and Feature flags show it). */\nexport interface SdkInfo {\n v: string;\n errors: boolean;\n /** \"web\" (script tag), \"ios\" or \"android\" (React Native). Missing from the Next.js provider. */\n platform?: string;\n}\n\n/** UTF-8 length of a string, the way TextEncoder counts it (a lone surrogate becomes U+FFFD, three bytes). */\nexport const byteLength = (s: string) => {\n let n = 0;\n for (let i = 0; i < s.length; i++) {\n const c = s.charCodeAt(i);\n if (c < 0x80) n += 1;\n else if (c < 0x800) n += 2;\n else if (c >= 0xd800 && c <= 0xdbff && i + 1 < s.length && (s.charCodeAt(i + 1) & 0xfc00) === 0xdc00) {\n n += 4;\n i++;\n } else n += 3;\n }\n return n;\n};\n\n/** One request: its body and the events in it (so a client can keep the ones that did not arrive). */\nexport interface BatchRequest<E> {\n body: string;\n events: E[];\n}\n\n/**\n * Splits events into request bodies of at most 100 events each, under the size limit. An event too large on its own is\n * dropped (it is in no request).\n */\nexport const batchRequests = <E extends CockpitEvent>(key: string, events: E[], sdk: SdkInfo): BatchRequest<E>[] => {\n const head = `{\"key\":${JSON.stringify(key)},\"sdk\":${JSON.stringify(sdk)},\"events\":[`;\n const empty = byteLength(head) + 2;\n const out: BatchRequest<E>[] = [];\n let chunk: string[] = [];\n let items: E[] = [];\n let size = empty;\n const close = () => {\n if (chunk.length) out.push({ body: `${head}${chunk.join(\",\")}]}`, events: items });\n chunk = [];\n items = [];\n size = empty;\n };\n for (const event of events) {\n const json = JSON.stringify(event);\n const n = byteLength(json) + 1;\n if (empty + n > MAX_BYTES) continue;\n if (chunk.length === MAX_BATCH || size + n > MAX_BYTES) close();\n chunk.push(json);\n items.push(event);\n size += n;\n }\n close();\n return out;\n};\n\n/**\n * Request bodies of at most 100 events each, under the size limit. An event too large on its own is dropped. `sdk` tells\n * MRRocket which SDK the site runs and whether it reports errors (Build › Errors and Feature flags show it).\n */\nexport const bodies = (key: string, events: CockpitEvent[], sdk: SdkInfo) => batchRequests(key, events, sdk).map((r) => r.body);\n"],"mappings":";AAQO,IAAM,YAAY;AAClB,IAAM,YAAY;AAWlB,IAAM,aAAa,CAAC,MAAc;AACrC,MAAI,IAAI;AACR,WAAS,IAAI,GAAG,IAAI,EAAE,QAAQ,KAAK;AAC/B,UAAM,IAAI,EAAE,WAAW,CAAC;AACxB,QAAI,IAAI,IAAM,MAAK;AAAA,aACV,IAAI,KAAO,MAAK;AAAA,aAChB,KAAK,SAAU,KAAK,SAAU,IAAI,IAAI,EAAE,WAAW,EAAE,WAAW,IAAI,CAAC,IAAI,WAAY,OAAQ;AAClG,WAAK;AACL;AAAA,IACJ,MAAO,MAAK;AAAA,EAChB;AACA,SAAO;AACX;AAYO,IAAM,gBAAgB,CAAyB,KAAa,QAAa,QAAoC;AAChH,QAAM,OAAO,UAAU,KAAK,UAAU,GAAG,CAAC,UAAU,KAAK,UAAU,GAAG,CAAC;AACvE,QAAM,QAAQ,WAAW,IAAI,IAAI;AACjC,QAAM,MAAyB,CAAC;AAChC,MAAI,QAAkB,CAAC;AACvB,MAAI,QAAa,CAAC;AAClB,MAAI,OAAO;AACX,QAAM,QAAQ,MAAM;AAChB,QAAI,MAAM,OAAQ,KAAI,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,MAAM,KAAK,GAAG,CAAC,MAAM,QAAQ,MAAM,CAAC;AACjF,YAAQ,CAAC;AACT,YAAQ,CAAC;AACT,WAAO;AAAA,EACX;AACA,aAAW,SAAS,QAAQ;AACxB,UAAM,OAAO,KAAK,UAAU,KAAK;AACjC,UAAM,IAAI,WAAW,IAAI,IAAI;AAC7B,QAAI,QAAQ,IAAI,UAAW;AAC3B,QAAI,MAAM,WAAW,aAAa,OAAO,IAAI,UAAW,OAAM;AAC9D,UAAM,KAAK,IAAI;AACf,UAAM,KAAK,KAAK;AAChB,YAAQ;AAAA,EACZ;AACA,QAAM;AACN,SAAO;AACX;AAMO,IAAM,SAAS,CAAC,KAAa,QAAwB,QAAiB,cAAc,KAAK,QAAQ,GAAG,EAAE,IAAI,CAAC,MAAM,EAAE,IAAI;","names":[]}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
(function(){'use strict';var St=Object.defineProperty;var Cr=(e,t,r)=>t in e?St(e,t,{enumerable:true,configurable:true,writable:true,value:r}):e[t]=r;var Mr=(e,t)=>()=>(e&&(t=e(e=0)),t);var Ir=(e,t)=>{for(var r in t)St(e,r,{get:t[r],enumerable:true});};var ge=(e,t,r)=>Cr(e,typeof t!="symbol"?t+"":t,r);var br={};Ir(br,{record:()=>Ie});function ht(e){if(xe[e])return xe[e];let t=globalThis[e],r=t.prototype,n=e in Nt?Nt[e]:void 0,s=!!(n&&n.every(c=>{var i,p;return !!((p=(i=Object.getOwnPropertyDescriptor(r,c))==null?void 0:i.get)!=null&&p.toString().includes("[native code]"))})),o=e in Lt?Lt[e]:void 0,a=!!(o&&o.every(c=>{var i;return typeof r[c]=="function"&&((i=r[c])==null?void 0:i.toString().includes("[native code]"))}));if(s&&a&&!Lr())return xe[e]=t.prototype,t.prototype;try{let c=document.createElement("iframe");c.style.display="none",document.body.appendChild(c);let i=c.contentWindow;if(!i)return t.prototype;let p=i[e].prototype;if(!p)return c.remove(),r;let u=navigator.userAgent;return u.includes("Safari")&&!u.includes("Chrome")?(c.classList.add("rr-block"),c.setAttribute("__rrwebUntaintedMutationObserver",""),jt[e]=()=>c.remove()):c.remove(),xe[e]=p}catch(c){return r}}function J(e,t,r){var n,s;let o=(n=Je[e])==null?void 0:n[r];if(o)return o.call(t);let a=ht(e),c=(s=Object.getOwnPropertyDescriptor(a,r))==null?void 0:s.get;return c?((Je[e]||(Je[e]={}))[r]=c,c.call(t)):t[r]}function Vt(e,t,r){let n=`${e}.${String(r)}`;if(Qe[n])return Qe[n].bind(t);let o=ht(e)[r];return typeof o!="function"?t[r]:(Qe[n]=o,o.bind(t))}function _r(e){return J("Node",e,"ownerDocument")}function Dr(e){return J("Node",e,"childNodes")}function Ar(e){return J("Node",e,"parentNode")}function Fr(e){return J("Node",e,"parentElement")}function Pr(e){return J("Node",e,"textContent")}function Ur(e){return J("Node",e,"firstChild")}function Wr(e){return J("Node",e,"lastChild")}function Br(e){return J("Node",e,"nextSibling")}function Hr(e){return J("Node",e,"previousSibling")}function zr(e,t){return Vt("Node",e,"contains")(t)}function $r(e){return Vt("Node",e,"getRootNode")()}function jr(e){return !e||!("host"in e)?null:J("ShadowRoot",e,"host")}function Vr(e){return e.styleSheets}function Gr(e){return !e||!("shadowRoot"in e)?null:J("Element",e,"shadowRoot")}function qr(e,t){return J("Element",e,"querySelector")(t)}function Kr(e,t){return J("Element",e,"querySelectorAll")(t)}function Gt(){var e;return [ht("MutationObserver").constructor,(e=jt.MutationObserver)!=null?e:(()=>{})]}function ae(e,t,r){try{if(!(t in e))return ()=>{};let n=e[t],s=r(n);return typeof s=="function"&&(s.prototype=s.prototype||{},Object.defineProperties(s,{__rrweb_original__:{enumerable:!1,value:n}})),e[t]=s,()=>{e[t]=n;}}catch(n){return ()=>{}}}function qt(e){return e.nodeType===e.ELEMENT_NODE}function be(e){let t=e&&"host"in e&&"mode"in e&&S.host(e)||null;return !!(t&&"shadowRoot"in t&&S.shadowRoot(t)===e)}function Se(e){return Object.prototype.toString.call(e)==="[object ShadowRoot]"}function Xr(e){return e.includes(" background-clip: text;")&&!e.includes(" -webkit-background-clip: text;")&&(e=e.replace(/\sbackground-clip:\s*text;/g," -webkit-background-clip: text; background-clip: text;")),e}function Yr(e){let{cssText:t}=e;if(t.split('"').length<3)return t;let r=["@import",`url(${JSON.stringify(e.href)})`];return e.layerName===""?r.push("layer"):e.layerName&&r.push(`layer(${e.layerName})`),e.supportsText&&r.push(`supports(${e.supportsText})`),e.media.length&&r.push(e.media.mediaText),r.join(" ")+";"}function tt(e){try{let t=e.rules||e.cssRules;if(!t)return null;let r=e.href;!r&&e.ownerNode&&(r=e.ownerNode.baseURI);let n=Array.from(t,s=>Kt(s,r)).join("");return Xr(n)}catch(t){return null}}function Kt(e,t){if(Qr(e)){let r;try{r=tt(e.styleSheet)||Yr(e);}catch(n){r=e.cssText;}return e.styleSheet.href?Pe(r,e.styleSheet.href):r}else {let r=e.cssText;return Zr(e)&&e.selectorText.includes(":")&&(r=Jr(r)),t?Pe(r,t):r}}function Jr(e){let t=/(\[(?:[\w-]+)[^\\])(:(?:[\w-]+)\])/gm;return e.replace(t,"$1\\$2")}function Qr(e){return "styleSheet"in e}function Zr(e){return "selectorText"in e}function en(){return new De}function Ae({element:e,maskInputOptions:t,tagName:r,type:n,value:s,maskInputFn:o}){let a=s||"",c=n&&ne(n);return (t[r.toLowerCase()]||c&&t[c])&&(o?a=o(a,e):a="*".repeat(a.length)),a}function ne(e){return e.toLowerCase()}function tn(e){let t=e.getContext("2d");if(!t)return true;let r=50;for(let n=0;n<e.width;n+=r)for(let s=0;s<e.height;s+=r){let o=t.getImageData,a=_t in o?o[_t]:o;if(new Uint32Array(a.call(t,n,s,Math.min(r,e.width-n),Math.min(r,e.height-s)).data.buffer).some(i=>i!==0))return false}return true}function Fe(e){let t=e.type;return e.hasAttribute("data-rr-is-password")?"password":t?ne(t):null}function Xt(e,t){var o;let r;try{r=new URL(e,t!=null?t:window.location.href);}catch(a){return null}let n=/\.([0-9a-z]+)(?:$)/i,s=r.pathname.match(n);return (o=s==null?void 0:s[1])!=null?o:null}function rn(e){let t="";return e.indexOf("//")>-1?t=e.split("/").slice(0,3).join("/"):t=e.split("/")[0],t=t.split("?")[0],t}function Pe(e,t){return (e||"").replace(nn,(r,n,s,o,a,c)=>{let i=s||a||c,p=n||o||"";if(!i)return r;if(sn.test(i)||on.test(i))return `url(${p}${i}${p})`;if(an.test(i))return `url(${p}${i}${p})`;if(i[0]==="/")return `url(${p}${rn(t)+i}${p})`;let u=i.split("#")[0],d=i.substring(u.length),h=t.split("#")[0].split("/"),f=u.split("/");h.pop();for(let m of f)m!=="."&&(m===".."?h.pop():h.push(m));return `url(${p}${h.join("/")}${d}${p})`})}function Oe(e,t=false){return t?e.replace(/(\/\*[^*]*\*\/)|[\s;]/g,""):e.replace(/(\/\*[^*]*\*\/)|[\s;]/g,"").replace(/0px/g,"0")}function ln(e,t,r=false){let n=Array.from(t.childNodes),s=[],o=0;if(n.length>1&&e&&typeof e=="string"){let a=Oe(e,r),c=a.length/e.length;for(let i=1;i<n.length;i++)if(n[i].textContent&&typeof n[i].textContent=="string"){let p=Oe(n[i].textContent,r),u=100,d=3;for(;d<p.length&&(p[d].match(/[a-zA-Z0-9]/)||p.indexOf(p.substring(0,d),1)!==-1);d++);for(;d<p.length;d++){let h=p.substring(0,d),f=a.split(h),m=-1;if(f.length===2)m=f[0].length;else if(f.length>2&&f[0]===""&&n[i-1].textContent!=="")m=a.indexOf(h,1);else if(f.length===1){if(h=h.substring(0,h.length-1),f=a.split(h),f.length<=1)return s.push(e),s;d=u+1;}else d===p.length-1&&(m=a.indexOf(h));if(f.length>=2&&d>u){let l=n[i-1].textContent;if(l&&typeof l=="string"){let b=Oe(l).length;m=a.indexOf(h,b);}m===-1&&(m=f[0].length);}if(m!==-1){let l=Math.floor(m/c);for(;l>0&&l<e.length;){if(o+=1,o>50*n.length)return s.push(e),s;let b=Oe(e.substring(0,l),r);if(b.length===m){s.push(e.substring(0,l)),e=e.substring(l),a=a.substring(m);break}else b.length<m?l+=Math.max(1,Math.floor((m-b.length)/c)):l-=Math.max(1,Math.floor((b.length-m)*c));}break}}}}return s.push(e),s}function cn(e,t){return ln(e,t).join("/* rr_split */")}function Yt(){return un++}function pn(e){if(e instanceof HTMLFormElement)return "form";let t=ne(e.tagName);return dn.test(t)?"div":t}function mn(e,t){if(t.trim()==="")return t;let r=0;function n(o){let a,c=o.exec(t.substring(r));return c?(a=c[0],r+=a.length,a):""}let s=[];for(;n(fn),!(r>=t.length);){let o=n(hn);if(o.slice(-1)===",")o=pe(e,o.substring(0,o.length-1)),s.push(o);else {let a="";o=pe(e,o);let c=false;for(;;){let i=t.charAt(r);if(i===""){s.push((o+a).trim());break}else if(c)i===")"&&(c=false);else if(i===","){r+=1,s.push((o+a).trim());break}else i==="("&&(c=true);a+=i,r+=1;}}}return s.join(", ")}function pe(e,t){return !t||t.trim()===""?t:ft(e,t)}function gn(e){return !!(e.tagName==="svg"||e.ownerSVGElement)}function ft(e,t){let r=At.get(e);if(r||(r=e.createElement("a"),At.set(e,r)),!t)t="";else if(t.startsWith("blob:")||t.startsWith("data:"))return t;return r.setAttribute("href",t),r.href}function Jt(e,t,r,n){return n&&(r==="src"||r==="href"&&!(t==="use"&&n[0]==="#")||r==="xlink:href"&&n[0]!=="#"||r==="background"&&["table","td","th"].includes(t)?pe(e,n):r==="srcset"?mn(e,n):r==="style"?Pe(n,ft(e)):t==="object"&&r==="data"?pe(e,n):n)}function Qt(e,t,r){return ["video","audio"].includes(e)&&ne(t)==="autoplay"}function yn(e,t,r){try{if(typeof t=="string"){if(e.classList.contains(t))return !0}else for(let n=e.classList.length;n--;){let s=e.classList[n];if(t.test(s))return !0}if(r)return e.matches(r)}catch(n){}return false}function We(e,t,r){if(!e)return false;if(e.nodeType!==e.ELEMENT_NODE)return r?We(S.parentNode(e),t,r):false;for(let n=e.classList.length;n--;){let s=e.classList[n];if(t.test(s))return true}return r?We(S.parentNode(e),t,r):false}function Zt(e,t,r,n){let s;if(qt(e)){if(s=e,!S.childNodes(s).length)return false}else {if(S.parentElement(e)===null)return false;s=S.parentElement(e);}try{if(typeof t=="string"){if(n){if(s.closest(`.${t}`))return !0}else if(s.classList.contains(t))return !0}else if(We(s,t,n))return !0;if(r){if(n){if(s.closest(r))return !0}else if(s.matches(r))return !0}}catch(o){}return false}function bn(e,t,r){let n=e.contentWindow;if(!n)return;let s=false,o;try{o=n.document.readyState;}catch(c){return}if(o!=="complete"){let c=setTimeout(()=>{s||(t(),s=true);},r);e.addEventListener("load",()=>{clearTimeout(c),s=true,t();});return}let a="about:blank";if(n.location.href!==a||e.src===a||e.src==="")return setTimeout(t,0),e.addEventListener("load",t);e.addEventListener("load",t);}function Sn(e,t,r){let n=false,s;try{s=e.sheet;}catch(a){return}if(s)return;let o=setTimeout(()=>{n||(t(),n=true);},r);e.addEventListener("load",()=>{clearTimeout(o),n=true,t();});}function wn(e,t){let{doc:r,mirror:n,blockClass:s,blockSelector:o,needsMask:a,inlineStylesheet:c,maskInputOptions:i={},maskTextFn:p,maskInputFn:u,dataURLOptions:d={},inlineImages:h,recordCanvas:f,keepIframeSrcFn:m,newlyAddedElement:l=false,cssCaptured:b=false}=t,C=vn(r,n);switch(e.nodeType){case e.DOCUMENT_NODE:return e.compatMode!=="CSS1Compat"?{type:B.Document,childNodes:[],compatMode:e.compatMode}:{type:B.Document,childNodes:[]};case e.DOCUMENT_TYPE_NODE:return {type:B.DocumentType,name:e.name,publicId:e.publicId,systemId:e.systemId,rootId:C};case e.ELEMENT_NODE:return Mn(e,{doc:r,blockClass:s,blockSelector:o,inlineStylesheet:c,maskInputOptions:i,maskInputFn:u,dataURLOptions:d,inlineImages:h,recordCanvas:f,keepIframeSrcFn:m,newlyAddedElement:l,rootId:C});case e.TEXT_NODE:return Cn(e,{doc:r,needsMask:a,maskTextFn:p,rootId:C,cssCaptured:b});case e.CDATA_SECTION_NODE:return {type:B.CDATA,textContent:"",rootId:C};case e.COMMENT_NODE:return {type:B.Comment,textContent:S.textContent(e)||"",rootId:C};default:return false}}function vn(e,t){if(!t.hasNode(e))return;let r=t.getId(e);return r===1?void 0:r}function Cn(e,t){let{needsMask:r,maskTextFn:n,rootId:s,cssCaptured:o}=t,a=S.parentNode(e),c=a&&a.tagName,i="",p=c==="STYLE"?true:void 0,u=c==="SCRIPT"?true:void 0;return u?i="SCRIPT_PLACEHOLDER":o||(i=S.textContent(e),p&&i&&(i=Pe(i,ft(t.doc)))),!p&&!u&&i&&r&&(i=n?n(i,S.parentElement(e)):i.replace(/[\S]/g,"*")),{type:B.Text,textContent:i||"",rootId:s}}function Mn(e,t){let{doc:r,blockClass:n,blockSelector:s,inlineStylesheet:o,maskInputOptions:a={},maskInputFn:c,dataURLOptions:i={},inlineImages:p,recordCanvas:u,keepIframeSrcFn:d,newlyAddedElement:h=false,rootId:f}=t,m=yn(e,n,s),l=pn(e),b={},C=e.attributes.length;for(let g=0;g<C;g++){let I=e.attributes[g];Qt(l,I.name,I.value)||(b[I.name]=Jt(r,l,ne(I.name),I.value));}if(l==="link"&&o){let g=Array.from(r.styleSheets).find(L=>L.href===e.href),I=null;g&&(I=tt(g)),I&&(delete b.rel,delete b.href,b._cssText=I);}if(l==="style"&&e.sheet){let g=tt(e.sheet);g&&(e.childNodes.length>1&&(g=cn(g,e)),b._cssText=g);}if(["input","textarea","select"].includes(l)){let g=e.value,I=e.checked;b.type!=="radio"&&b.type!=="checkbox"&&b.type!=="submit"&&b.type!=="button"&&g?b.value=Ae({element:e,type:Fe(e),tagName:l,value:g,maskInputOptions:a,maskInputFn:c}):I&&(b.checked=I);}if(l==="option"&&(e.selected&&!a.select?b.selected=true:delete b.selected),l==="dialog"&&e.open&&(b.rr_open_mode=e.matches("dialog:modal")?"modal":"non-modal"),l==="canvas"&&u){if(e.__context==="2d")tn(e)||(b.rr_dataURL=e.toDataURL(i.type,i.quality));else if(!("__context"in e)){let g=e.toDataURL(i.type,i.quality),I=r.createElement("canvas");I.width=e.width,I.height=e.height;let L=I.toDataURL(i.type,i.quality);g!==L&&(b.rr_dataURL=g);}}if(l==="img"&&p){ce||(ce=r.createElement("canvas"),Dt=ce.getContext("2d"));let g=e,I=g.currentSrc||g.getAttribute("src")||"<unknown-src>",L=g.crossOrigin,D=()=>{g.removeEventListener("load",D);try{ce.width=g.naturalWidth,ce.height=g.naturalHeight,Dt.drawImage(g,0,0),b.rr_dataURL=ce.toDataURL(i.type,i.quality);}catch(H){if(g.crossOrigin!=="anonymous"){g.crossOrigin="anonymous",g.complete&&g.naturalWidth!==0?D():g.addEventListener("load",D);return}else console.warn(`Cannot inline img src=${I}! Error: ${H}`);}g.crossOrigin==="anonymous"&&(L?b.crossOrigin=L:g.removeAttribute("crossorigin"));};g.complete&&g.naturalWidth!==0?D():g.addEventListener("load",D);}if(["audio","video"].includes(l)){let g=b;g.rr_mediaState=e.paused?"paused":"played",g.rr_mediaCurrentTime=e.currentTime,g.rr_mediaPlaybackRate=e.playbackRate,g.rr_mediaMuted=e.muted,g.rr_mediaLoop=e.loop,g.rr_mediaVolume=e.volume;}if(h||(e.scrollLeft&&(b.rr_scrollLeft=e.scrollLeft),e.scrollTop&&(b.rr_scrollTop=e.scrollTop)),m){let{width:g,height:I}=e.getBoundingClientRect();b={class:b.class,rr_width:`${g}px`,rr_height:`${I}px`};}l==="iframe"&&!d(b.src)&&(e.contentDocument||(b.rr_src=b.src),delete b.src);let w;try{customElements.get(l)&&(w=!0);}catch(g){}return {type:B.Element,tagName:l,attributes:b,childNodes:[],isSVG:gn(e)||void 0,needBlock:m,rootId:f,isCustom:w}}function _(e){return e==null?"":e.toLowerCase()}function er(e){return e===true||e==="all"?{script:true,comment:true,headFavicon:true,headWhitespace:true,headMetaSocial:true,headMetaRobots:true,headMetaHttpEquiv:true,headMetaVerification:true,headMetaAuthorship:e==="all",headMetaDescKeywords:e==="all",headTitleMutations:e==="all"}:e||{}}function In(e,t){if(t.comment&&e.type===B.Comment)return true;if(e.type===B.Element){if(t.script&&(e.tagName==="script"||e.tagName==="link"&&(e.attributes.rel==="preload"&&e.attributes.as==="script"||e.attributes.rel==="modulepreload")||e.tagName==="link"&&e.attributes.rel==="prefetch"&&typeof e.attributes.href=="string"&&Xt(e.attributes.href)==="js"))return true;if(t.headFavicon&&(e.tagName==="link"&&e.attributes.rel==="shortcut icon"||e.tagName==="meta"&&(_(e.attributes.name).match(/^msapplication-tile(image|color)$/)||_(e.attributes.name)==="application-name"||_(e.attributes.rel)==="icon"||_(e.attributes.rel)==="apple-touch-icon"||_(e.attributes.rel)==="shortcut icon")))return true;if(e.tagName==="meta"){if(t.headMetaDescKeywords&&_(e.attributes.name).match(/^description|keywords$/))return true;if(t.headMetaSocial&&(_(e.attributes.property).match(/^(og|twitter|fb):/)||_(e.attributes.name).match(/^(og|twitter):/)||_(e.attributes.name)==="pinterest"))return true;if(t.headMetaRobots&&(_(e.attributes.name)==="robots"||_(e.attributes.name)==="googlebot"||_(e.attributes.name)==="bingbot"))return true;if(t.headMetaHttpEquiv&&e.attributes["http-equiv"]!==void 0)return true;if(t.headMetaAuthorship&&(_(e.attributes.name)==="author"||_(e.attributes.name)==="generator"||_(e.attributes.name)==="framework"||_(e.attributes.name)==="publisher"||_(e.attributes.name)==="progid"||_(e.attributes.property).match(/^article:/)||_(e.attributes.property).match(/^product:/)))return true;if(t.headMetaVerification&&(_(e.attributes.name)==="google-site-verification"||_(e.attributes.name)==="yandex-verification"||_(e.attributes.name)==="csrf-token"||_(e.attributes.name)==="p:domain_verify"||_(e.attributes.name)==="verify-v1"||_(e.attributes.name)==="verification"||_(e.attributes.name)==="shopify-checkout-api-token"))return true}}return false}function he(e,t){let{doc:r,mirror:n,blockClass:s,blockSelector:o,maskTextClass:a,maskTextSelector:c,skipChild:i=false,inlineStylesheet:p=true,maskInputOptions:u={},maskTextFn:d,maskInputFn:h,slimDOMOptions:f,dataURLOptions:m={},inlineImages:l=false,recordCanvas:b=false,onSerialize:C,onIframeLoad:w,iframeLoadTimeout:g=5e3,onStylesheetLoad:I,stylesheetLoadTimeout:L=5e3,keepIframeSrcFn:D=()=>false,newlyAddedElement:H=false,cssCaptured:X=false}=t,{needsMask:z}=t,{preserveWhiteSpace:q=true}=t;z||(z=Zt(e,a,c,z===void 0));let $=wn(e,{doc:r,mirror:n,blockClass:s,blockSelector:o,needsMask:z,inlineStylesheet:p,maskInputOptions:u,maskTextFn:d,maskInputFn:h,dataURLOptions:m,inlineImages:l,recordCanvas:b,keepIframeSrcFn:D,newlyAddedElement:H,cssCaptured:X});if(!$)return console.warn(e,"not serialized"),null;let j;n.hasNode(e)?j=n.getId(e):In($,f)||!q&&$.type===B.Text&&!$.textContent.replace(/^\s+|\s+$/gm,"").length?j=Ue:j=Yt();let E=Object.assign($,{id:j});if(n.add(e,E),j===Ue)return null;C&&C(e);let te=!i;if(E.type===B.Element){te=te&&!E.needBlock,delete E.needBlock;let v=S.shadowRoot(e);v&&Se(v)&&(E.isShadowHost=true);}if((E.type===B.Document||E.type===B.Element)&&te){f.headWhitespace&&E.type===B.Element&&E.tagName==="head"&&(q=false);let v={doc:r,mirror:n,blockClass:s,blockSelector:o,needsMask:z,maskTextClass:a,maskTextSelector:c,skipChild:i,inlineStylesheet:p,maskInputOptions:u,maskTextFn:d,maskInputFn:h,slimDOMOptions:f,dataURLOptions:m,inlineImages:l,recordCanvas:b,preserveWhiteSpace:q,onSerialize:C,onIframeLoad:w,iframeLoadTimeout:g,onStylesheetLoad:I,stylesheetLoadTimeout:L,keepIframeSrcFn:D,cssCaptured:false};if(!(E.type===B.Element&&E.tagName==="textarea"&&E.attributes.value!==void 0)){E.type===B.Element&&E.attributes._cssText!==void 0&&typeof E.attributes._cssText=="string"&&(v.cssCaptured=true);for(let A of Array.from(S.childNodes(e))){let F=he(A,v);F&&E.childNodes.push(F);}}let O=null;if(qt(e)&&(O=S.shadowRoot(e)))for(let A of Array.from(S.childNodes(O))){let F=he(A,v);F&&(Se(O)&&(F.isShadow=true),E.childNodes.push(F));}}let M=S.parentNode(e);return M&&be(M)&&Se(M)&&(E.isShadow=true),E.type===B.Element&&E.tagName==="iframe"&&bn(e,()=>{let v=e.contentDocument;if(v&&w){let O=he(v,{doc:v,mirror:n,blockClass:s,blockSelector:o,needsMask:z,maskTextClass:a,maskTextSelector:c,skipChild:false,inlineStylesheet:p,maskInputOptions:u,maskTextFn:d,maskInputFn:h,slimDOMOptions:f,dataURLOptions:m,inlineImages:l,recordCanvas:b,preserveWhiteSpace:q,onSerialize:C,onIframeLoad:w,iframeLoadTimeout:g,onStylesheetLoad:I,stylesheetLoadTimeout:L,keepIframeSrcFn:D});O&&w(e,O);}},g),E.type===B.Element&&E.tagName==="link"&&typeof E.attributes.rel=="string"&&(E.attributes.rel==="stylesheet"||E.attributes.rel==="preload"&&typeof E.attributes.href=="string"&&Xt(E.attributes.href)==="css")&&Sn(e,()=>{if(I){let v=he(e,{doc:r,mirror:n,blockClass:s,blockSelector:o,needsMask:z,maskTextClass:a,maskTextSelector:c,skipChild:false,inlineStylesheet:p,maskInputOptions:u,maskTextFn:d,maskInputFn:h,slimDOMOptions:f,dataURLOptions:m,inlineImages:l,recordCanvas:b,preserveWhiteSpace:q,onSerialize:C,onIframeLoad:w,iframeLoadTimeout:g,onStylesheetLoad:I,stylesheetLoadTimeout:L,keepIframeSrcFn:D});v&&I(e,v);}},L),E}function Rn(e,t){let{mirror:r=new De,blockClass:n="rr-block",blockSelector:s=null,maskTextClass:o="rr-mask",maskTextSelector:a=null,inlineStylesheet:c=true,inlineImages:i=false,recordCanvas:p=false,maskAllInputs:u=false,maskTextFn:d,maskInputFn:h,slimDOM:f=false,dataURLOptions:m,preserveWhiteSpace:l,onSerialize:b,onIframeLoad:C,iframeLoadTimeout:w,onStylesheetLoad:g,stylesheetLoadTimeout:I,keepIframeSrcFn:L=()=>false}=t,D=u===true?{color:true,date:true,"datetime-local":true,email:true,month:true,number:true,range:true,search:true,tel:true,text:true,time:true,url:true,week:true,textarea:true,select:true,password:true}:u===false?{password:true}:u,H=er(f);return he(e,{doc:e,mirror:r,blockClass:n,blockSelector:s,maskTextClass:o,maskTextSelector:a,skipChild:false,inlineStylesheet:c,maskInputOptions:D,maskTextFn:d,maskInputFn:h,slimDOMOptions:H,dataURLOptions:m,inlineImages:i,recordCanvas:p,preserveWhiteSpace:l,onSerialize:b,onIframeLoad:C,iframeLoadTimeout:w,onStylesheetLoad:g,stylesheetLoadTimeout:I,keepIframeSrcFn:L,newlyAddedElement:false})}function V(e,t,r=document){let n={capture:true,passive:true};return r.addEventListener(e,t,n),()=>r.removeEventListener(e,t,n)}function Ce(e,t,r={}){let n=null,s=0;return function(...o){let a=Date.now();!s&&r.leading===false&&(s=a);let c=t-(a-s),i=this;c<=0||c>t?(n&&(clearTimeout(n),n=null),s=a,e.apply(i,o)):!n&&r.trailing!==false&&(n=setTimeout(()=>{s=r.leading===false?0:Date.now(),n=null,e.apply(i,o);},c));}}function $e(e,t,r,n,s=window){let o=s.Object.getOwnPropertyDescriptor(e,t);return s.Object.defineProperty(e,t,n?r:{set(a){setTimeout(()=>{r.set.call(this,a);},0),o&&o.set&&o.set.call(this,a);}}),()=>$e(e,t,o||{},true)}function tr(e){var t,r,n,s;let o=e.document;return {left:o.scrollingElement?o.scrollingElement.scrollLeft:e.pageXOffset!==void 0?e.pageXOffset:o.documentElement.scrollLeft||(o==null?void 0:o.body)&&((t=S.parentElement(o.body))==null?void 0:t.scrollLeft)||((r=o==null?void 0:o.body)==null?void 0:r.scrollLeft)||0,top:o.scrollingElement?o.scrollingElement.scrollTop:e.pageYOffset!==void 0?e.pageYOffset:(o==null?void 0:o.documentElement.scrollTop)||(o==null?void 0:o.body)&&((n=S.parentElement(o.body))==null?void 0:n.scrollTop)||((s=o==null?void 0:o.body)==null?void 0:s.scrollTop)||0}}function rr(){return window.innerHeight||document.documentElement&&document.documentElement.clientHeight||document.body&&document.body.clientHeight}function nr(){return window.innerWidth||document.documentElement&&document.documentElement.clientWidth||document.body&&document.body.clientWidth}function sr(e){return e?e.nodeType===e.ELEMENT_NODE?e:S.parentElement(e):null}function G(e,t,r,n){if(!e)return false;let s=sr(e);if(!s)return false;try{if(typeof t=="string"){if(s.classList.contains(t)||n&&s.closest("."+t)!==null)return !0}else if(We(s,t,n))return !0}catch(o){}return !!(r&&(s.matches(r)||n&&s.closest(r)!==null))}function En(e,t){return t.getId(e)!==-1}function Ze(e,t,r){return e.tagName==="TITLE"&&r.headTitleMutations?true:t.getId(e)===Ue}function or(e,t){if(be(e))return false;let r=t.getId(e);if(!t.has(r))return true;let n=S.parentNode(e);return n&&n.nodeType===e.DOCUMENT_NODE?false:n?or(n,t):true}function nt(e){return !!e.changedTouches}function kn(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);}function ir(e,t){return !!(e.nodeName==="IFRAME"&&t.getMeta(e))}function ar(e,t){return !!(e.nodeName==="LINK"&&e.nodeType===e.ELEMENT_NODE&&e.getAttribute&&e.getAttribute("rel")==="stylesheet"&&t.getMeta(e))}function st(e){return e?e instanceof rt&&"shadowRoot"in e?!!e.shadowRoot:!!S.shadowRoot(e):false}function lr(e){var t;let r=null;return "getRootNode"in e&&((t=S.getRootNode(e))==null?void 0:t.nodeType)===Node.DOCUMENT_FRAGMENT_NODE&&S.host(S.getRootNode(e))&&(r=S.host(S.getRootNode(e))),r}function xn(e){let t=e,r;for(;r=lr(t);)t=r;return t}function On(e){let t=S.ownerDocument(e);if(!t)return false;let r=xn(e);return S.contains(t,r)}function cr(e){let t=S.ownerDocument(e);return t?S.contains(t,e)||On(e):false}function at(e,t){e.delete(t),S.childNodes(t).forEach(r=>at(e,r));}function Tn(e,t){let r=[e];for(;r.length;){let n=r.pop();t.has(n)||(t.add(n),S.childNodes(n).forEach(s=>r.push(s)));}}function Ut(e,t){return e.size===0?false:ur(e,t)}function ur(e,t){if(e.has(t))return true;let r=S.parentNode(t);return r?ur(e,r):false}function Nn(e){we=e;}function Ln(){we=void 0;}function Me(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]}catch(t){}return e&&e.target}function dr(e,t){let r=new it;ie.push(r),r.init(e);let[n,s]=Gt(),o=new n(k(r.processMutations.bind(r)));return o.observe(t,{attributes:true,attributeOldValue:true,characterData:true,characterDataOldValue:true,childList:true,subtree:true}),[o,s]}function _n({mousemoveCb:e,sampling:t,doc:r,mirror:n}){if(t.mousemove===false)return ()=>{};let s=typeof t.mousemove=="number"?t.mousemove:50,o=typeof t.mousemoveCallback=="number"?t.mousemoveCallback:500,a=[],c,i=Ce(k(d=>{let h=Date.now()-c;e(a.map(f=>(f.timeOffset-=h,f)),d),a=[],c=null;}),o),p=k(Ce(k(d=>{let h=Me(d),{clientX:f,clientY:m}=nt(d)?d.changedTouches[0]:d;c||(c=ve()),a.push({x:f,y:m,id:n.getId(h),timeOffset:ve()-c}),i(typeof DragEvent!="undefined"&&d instanceof DragEvent?R.Drag:d instanceof MouseEvent?R.MouseMove:R.TouchMove);}),s,{trailing:!1})),u=[V("mousemove",p,r),V("touchmove",p,r),V("drag",p,r)];return k(()=>{u.forEach(d=>d());})}function Dn({mouseInteractionCb:e,doc:t,mirror:r,blockClass:n,blockSelector:s,sampling:o}){if(o.mouseInteraction===false)return ()=>{};let a=o.mouseInteraction===true||o.mouseInteraction===void 0?{}:o.mouseInteraction,c=[],i=null,p=u=>d=>{let h=Me(d);if(G(h,n,s,true))return;let f=null,m=u;if("pointerType"in d){switch(d.pointerType){case "mouse":f=ee.Mouse;break;case "touch":f=ee.Touch;break;case "pen":f=ee.Pen;break}f===ee.Touch?K[u]===K.MouseDown?m="TouchStart":K[u]===K.MouseUp&&(m="TouchEnd"):ee.Pen;}else nt(d)&&(f=ee.Touch);f!==null?(i=f,(m.startsWith("Touch")&&f===ee.Touch||m.startsWith("Mouse")&&f===ee.Mouse)&&(f=null)):K[u]===K.Click&&(f=i,i=null);let l=nt(d)?d.changedTouches[0]:d;if(!l)return;let b=r.getId(h),{clientX:C,clientY:w}=l;k(e)({type:K[m],id:b,x:C,y:w,...f!==null&&{pointerType:f}});};return Object.keys(K).filter(u=>Number.isNaN(Number(u))&&!u.endsWith("_Departed")&&a[u]!==false).forEach(u=>{let d=ne(u),h=p(u);if(window.PointerEvent)switch(K[u]){case K.MouseDown:case K.MouseUp:d=d.replace("mouse","pointer");break;case K.TouchStart:case K.TouchEnd:return}c.push(V(d,h,t));}),k(()=>{c.forEach(u=>u());})}function pr({scrollCb:e,doc:t,mirror:r,blockClass:n,blockSelector:s,sampling:o}){let a=k(Ce(k(c=>{let i=Me(c);if(!i||G(i,n,s,!0))return;let p=r.getId(i);if(i===t&&t.defaultView){let u=tr(t.defaultView);e({id:p,x:u.left,y:u.top});}else e({id:p,x:i.scrollLeft,y:i.scrollTop});}),o.scroll||100));return V("scroll",a,t)}function An({viewportResizeCb:e},{win:t}){let r=-1,n=-1,s=k(Ce(k(()=>{let o=rr(),a=nr();(r!==o||n!==a)&&(e({width:Number(a),height:Number(o)}),r=o,n=a);}),200));return V("resize",s,t)}function Pn({inputCb:e,doc:t,mirror:r,blockClass:n,blockSelector:s,ignoreClass:o,ignoreSelector:a,maskInputOptions:c,maskInputFn:i,sampling:p,userTriggeredOnInput:u}){function d(w){let g=Me(w),I=w.isTrusted,L=g&&g.tagName;if(g&&L==="OPTION"&&(g=S.parentElement(g)),!g||!L||Fn.indexOf(L)<0||G(g,n,s,true)||g.classList.contains(o)||a&&g.matches(a))return;let D=g.value,H=false,X=Fe(g)||"";X==="radio"||X==="checkbox"?H=g.checked:(c[L.toLowerCase()]||c[X])&&(D=Ae({element:g,maskInputOptions:c,tagName:L,type:X,value:D,maskInputFn:i})),h(g,u?{text:D,isChecked:H,userTriggered:I}:{text:D,isChecked:H});let z=g.name;X==="radio"&&z&&H&&t.querySelectorAll(`input[type="radio"][name="${z}"]`).forEach(q=>{if(q!==g){let $=q.value;h(q,u?{text:$,isChecked:!H,userTriggered:false}:{text:$,isChecked:!H});}});}function h(w,g){let I=Wt.get(w);if(!I||I.text!==g.text||I.isChecked!==g.isChecked){Wt.set(w,g);let L=r.getId(w);k(e)({...g,id:L});}}let m=(p.input==="last"?["change"]:["input","change"]).map(w=>V(w,k(d),t)),l=t.defaultView;if(!l)return ()=>{m.forEach(w=>w());};let b=l.Object.getOwnPropertyDescriptor(l.HTMLInputElement.prototype,"value"),C=[[l.HTMLInputElement.prototype,"value"],[l.HTMLInputElement.prototype,"checked"],[l.HTMLSelectElement.prototype,"value"],[l.HTMLTextAreaElement.prototype,"value"],[l.HTMLSelectElement.prototype,"selectedIndex"],[l.HTMLOptionElement.prototype,"selected"]];return b&&b.set&&m.push(...C.map(w=>$e(w[0],w[1],{set(){k(d)({target:this,isTrusted:false});}},false,l))),k(()=>{m.forEach(w=>w());})}function Be(e){let t=[];function r(n,s){if(Te("CSSGroupingRule")&&n.parentRule instanceof CSSGroupingRule||Te("CSSMediaRule")&&n.parentRule instanceof CSSMediaRule||Te("CSSSupportsRule")&&n.parentRule instanceof CSSSupportsRule||Te("CSSConditionRule")&&n.parentRule instanceof CSSConditionRule){let a=Array.from(n.parentRule.cssRules).indexOf(n);return s.unshift(a),r(n.parentRule,s)}else if(n.parentStyleSheet){let a=Array.from(n.parentStyleSheet.cssRules).indexOf(n);s.unshift(a);}return s}return r(e,t)}function re(e,t,r){let n,s;return e?(e.ownerNode?n=t.getId(e.ownerNode):s=r.getId(e),{styleId:s,id:n}):{}}function Un({styleSheetRuleCb:e,mirror:t,stylesheetManager:r},{win:n}){if(!n.CSSStyleSheet||!n.CSSStyleSheet.prototype)return ()=>{};let s=n.CSSStyleSheet.prototype.insertRule;n.CSSStyleSheet.prototype.insertRule=new Proxy(s,{apply:k((u,d,h)=>{let[f,m]=h,{id:l,styleId:b}=re(d,t,r.styleMirror);return (l&&l!==-1||b&&b!==-1)&&e({id:l,styleId:b,adds:[{rule:f,index:m}]}),u.apply(d,h)})}),n.CSSStyleSheet.prototype.addRule=function(u,d,h=this.cssRules.length){let f=`${u} { ${d} }`;return n.CSSStyleSheet.prototype.insertRule.apply(this,[f,h])};let o=n.CSSStyleSheet.prototype.deleteRule;n.CSSStyleSheet.prototype.deleteRule=new Proxy(o,{apply:k((u,d,h)=>{let[f]=h,{id:m,styleId:l}=re(d,t,r.styleMirror);return (m&&m!==-1||l&&l!==-1)&&e({id:m,styleId:l,removes:[{index:f}]}),u.apply(d,h)})}),n.CSSStyleSheet.prototype.removeRule=function(u){return n.CSSStyleSheet.prototype.deleteRule.apply(this,[u])};let a;n.CSSStyleSheet.prototype.replace&&(a=n.CSSStyleSheet.prototype.replace,n.CSSStyleSheet.prototype.replace=new Proxy(a,{apply:k((u,d,h)=>{let[f]=h,{id:m,styleId:l}=re(d,t,r.styleMirror);return (m&&m!==-1||l&&l!==-1)&&e({id:m,styleId:l,replace:f}),u.apply(d,h)})}));let c;n.CSSStyleSheet.prototype.replaceSync&&(c=n.CSSStyleSheet.prototype.replaceSync,n.CSSStyleSheet.prototype.replaceSync=new Proxy(c,{apply:k((u,d,h)=>{let[f]=h,{id:m,styleId:l}=re(d,t,r.styleMirror);return (m&&m!==-1||l&&l!==-1)&&e({id:m,styleId:l,replaceSync:f}),u.apply(d,h)})}));let i={};Ne("CSSGroupingRule")?i.CSSGroupingRule=n.CSSGroupingRule:(Ne("CSSMediaRule")&&(i.CSSMediaRule=n.CSSMediaRule),Ne("CSSConditionRule")&&(i.CSSConditionRule=n.CSSConditionRule),Ne("CSSSupportsRule")&&(i.CSSSupportsRule=n.CSSSupportsRule));let p={};return Object.entries(i).forEach(([u,d])=>{p[u]={insertRule:d.prototype.insertRule,deleteRule:d.prototype.deleteRule},d.prototype.insertRule=new Proxy(p[u].insertRule,{apply:k((h,f,m)=>{let[l,b]=m,{id:C,styleId:w}=re(f.parentStyleSheet,t,r.styleMirror);return (C&&C!==-1||w&&w!==-1)&&e({id:C,styleId:w,adds:[{rule:l,index:[...Be(f),b||0]}]}),h.apply(f,m)})}),d.prototype.deleteRule=new Proxy(p[u].deleteRule,{apply:k((h,f,m)=>{let[l]=m,{id:b,styleId:C}=re(f.parentStyleSheet,t,r.styleMirror);return (b&&b!==-1||C&&C!==-1)&&e({id:b,styleId:C,removes:[{index:[...Be(f),l]}]}),h.apply(f,m)})});}),k(()=>{n.CSSStyleSheet.prototype.insertRule=s,n.CSSStyleSheet.prototype.deleteRule=o,a&&(n.CSSStyleSheet.prototype.replace=a),c&&(n.CSSStyleSheet.prototype.replaceSync=c),Object.entries(i).forEach(([u,d])=>{d.prototype.insertRule=p[u].insertRule,d.prototype.deleteRule=p[u].deleteRule;});})}function hr({mirror:e,stylesheetManager:t},r){var n,s,o;let a=null;r.nodeName==="#document"?a=e.getId(r):a=e.getId(S.host(r));let c=r.nodeName==="#document"?(n=r.defaultView)==null?void 0:n.Document:(o=(s=r.ownerDocument)==null?void 0:s.defaultView)==null?void 0:o.ShadowRoot,i=c!=null&&c.prototype?Object.getOwnPropertyDescriptor(c==null?void 0:c.prototype,"adoptedStyleSheets"):void 0;return a===null||a===-1||!c||!i?()=>{}:(Object.defineProperty(r,"adoptedStyleSheets",{configurable:i.configurable,enumerable:i.enumerable,get(){var p;return (p=i.get)==null?void 0:p.call(this)},set(p){var u;let d=(u=i.set)==null?void 0:u.call(this,p);if(a!==null&&a!==-1)try{t.adoptStyleSheets(p,a);}catch(h){}return d}}),k(()=>{Object.defineProperty(r,"adoptedStyleSheets",{configurable:i.configurable,enumerable:i.enumerable,get:i.get,set:i.set});}))}function Wn({styleDeclarationCb:e,mirror:t,ignoreCSSAttributes:r,stylesheetManager:n},{win:s}){let o=s.CSSStyleDeclaration.prototype.setProperty;s.CSSStyleDeclaration.prototype.setProperty=new Proxy(o,{apply:k((c,i,p)=>{var u;let[d,h,f]=p;if(r.has(d))return o.apply(i,[d,h,f]);let{id:m,styleId:l}=re((u=i.parentRule)==null?void 0:u.parentStyleSheet,t,n.styleMirror);return (m&&m!==-1||l&&l!==-1)&&e({id:m,styleId:l,set:{property:d,value:h,priority:f},index:Be(i.parentRule)}),c.apply(i,p)})});let a=s.CSSStyleDeclaration.prototype.removeProperty;return s.CSSStyleDeclaration.prototype.removeProperty=new Proxy(a,{apply:k((c,i,p)=>{var u;let[d]=p;if(r.has(d))return a.apply(i,[d]);let{id:h,styleId:f}=re((u=i.parentRule)==null?void 0:u.parentStyleSheet,t,n.styleMirror);return (h&&h!==-1||f&&f!==-1)&&e({id:h,styleId:f,remove:{property:d},index:Be(i.parentRule)}),c.apply(i,p)})}),k(()=>{s.CSSStyleDeclaration.prototype.setProperty=o,s.CSSStyleDeclaration.prototype.removeProperty=a;})}function Bn({mediaInteractionCb:e,blockClass:t,blockSelector:r,mirror:n,sampling:s,doc:o}){let a=k(i=>Ce(k(p=>{let u=Me(p);if(!u||G(u,t,r,!0))return;let{currentTime:d,volume:h,muted:f,playbackRate:m,loop:l}=u;e({type:i,id:n.getId(u),currentTime:d,volume:h,muted:f,playbackRate:m,loop:l});}),s.media||500)),c=[V("play",a(ue.Play),o),V("pause",a(ue.Pause),o),V("seeked",a(ue.Seeked),o),V("volumechange",a(ue.VolumeChange),o),V("ratechange",a(ue.RateChange),o)];return k(()=>{c.forEach(i=>i());})}function Hn({fontCb:e,doc:t}){let r=t.defaultView;if(!r)return ()=>{};let n=[],s=new WeakMap,o=r.FontFace;r.FontFace=function(i,p,u){let d=new o(i,p,u);return s.set(d,{family:i,buffer:typeof p!="string",descriptors:u,fontSource:typeof p=="string"?p:JSON.stringify(Array.from(new Uint8Array(p)))}),d};let a=ae(t.fonts,"add",function(c){return function(i){return setTimeout(k(()=>{let p=s.get(i);p&&(e(p),s.delete(i));}),0),c.apply(this,[i])}});return n.push(()=>{r.FontFace=o;}),n.push(a),k(()=>{n.forEach(c=>c());})}function zn(e){let{doc:t,mirror:r,blockClass:n,blockSelector:s,selectionCb:o}=e,a=true,c=k(()=>{let i=t.getSelection();if(!i||a&&(i!=null&&i.isCollapsed))return;a=i.isCollapsed||false;let p=[],u=i.rangeCount||0;for(let d=0;d<u;d++){let h=i.getRangeAt(d),{startContainer:f,startOffset:m,endContainer:l,endOffset:b}=h;G(f,n,s,!0)||G(l,n,s,!0)||p.push({start:r.getId(f),startOffset:m,end:r.getId(l),endOffset:b});}o({ranges:p});});return c(),V("selectionchange",c)}function $n({doc:e,customElementCb:t}){let r=e.defaultView;return !r||!r.customElements?()=>{}:ae(r.customElements,"define",function(s){return function(o,a,c){try{t({define:{name:o}});}catch(i){console.warn(`Custom element callback failed for ${o}`);}return s.apply(this,[o,a,c])}})}function jn(e,t){let{mutationCb:r,mousemoveCb:n,mouseInteractionCb:s,scrollCb:o,viewportResizeCb:a,inputCb:c,mediaInteractionCb:i,styleSheetRuleCb:p,styleDeclarationCb:u,canvasMutationCb:d,fontCb:h,selectionCb:f,customElementCb:m}=e;e.mutationCb=(...l)=>{t.mutation&&t.mutation(...l),r(...l);},e.mousemoveCb=(...l)=>{t.mousemove&&t.mousemove(...l),n(...l);},e.mouseInteractionCb=(...l)=>{t.mouseInteraction&&t.mouseInteraction(...l),s(...l);},e.scrollCb=(...l)=>{t.scroll&&t.scroll(...l),o(...l);},e.viewportResizeCb=(...l)=>{t.viewportResize&&t.viewportResize(...l),a(...l);},e.inputCb=(...l)=>{t.input&&t.input(...l),c(...l);},e.mediaInteractionCb=(...l)=>{t.mediaInteaction&&t.mediaInteaction(...l),i(...l);},e.styleSheetRuleCb=(...l)=>{t.styleSheetRule&&t.styleSheetRule(...l),p(...l);},e.styleDeclarationCb=(...l)=>{t.styleDeclaration&&t.styleDeclaration(...l),u(...l);},e.canvasMutationCb=(...l)=>{t.canvasMutation&&t.canvasMutation(...l),d(...l);},e.fontCb=(...l)=>{t.font&&t.font(...l),h(...l);},e.selectionCb=(...l)=>{t.selection&&t.selection(...l),f(...l);},e.customElementCb=(...l)=>{t.customElement&&t.customElement(...l),m(...l);};}function Vn(e,t={}){let r=e.doc.defaultView;if(!r)return ()=>{};jn(e,t);let n,s=()=>{};e.recordDOM&&([n,s]=dr(e,e.doc));let o=_n(e),a=Dn(e),c=pr(e),i=An(e,{win:r}),p=Pn(e),u=Bn(e),d=()=>{},h=()=>{},f=()=>{},m=()=>{};e.recordDOM&&(d=Un(e,{win:r}),h=hr(e,e.doc),f=Wn(e,{win:r}),e.collectFonts&&(m=Hn(e)));let l=zn(e),b=$n(e),C=[];for(let w of e.plugins)C.push(w.observer(w.callback,r,w.options));return k(()=>{ie.forEach(w=>w.reset()),n==null||n.disconnect(),s(),o(),a(),c(),i(),p(),u(),d(),h(),f(),m(),l(),b(),C.forEach(w=>w());})}function Te(e){return typeof window[e]!="undefined"}function Ne(e){return !!(typeof window[e]!="undefined"&&window[e].prototype&&"insertRule"in window[e].prototype&&"deleteRule"in window[e].prototype)}function Kn(e,t){let r=Bt.get(e);return r||(r=new Map,Bt.set(e,r)),r.has(t)||r.set(t,[]),r.get(t)}function Le(e,t,r){if(e instanceof Array)return e.map(n=>Le(n,t,r));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){let n=e.constructor.name,s=qn(e);return {rr_type:n,base64:s}}else {if(e instanceof DataView)return {rr_type:e.constructor.name,args:[Le(e.buffer,t,r),e.byteOffset,e.byteLength]};if(e instanceof HTMLImageElement){let n=e.constructor.name,{src:s}=e;return {rr_type:n,src:s}}else if(e instanceof HTMLCanvasElement){let n="HTMLImageElement",s=e.toDataURL();return {rr_type:n,src:s}}else {if(e instanceof ImageData)return {rr_type:e.constructor.name,args:[Le(e.data,t,r),e.width,e.height]};if(gr(e,t)||typeof e=="object"){let n=e.constructor.name,s=fr(e,t,r);return {rr_type:n,index:s}}}}return e}function Xn(e,t,r,n){let s=[],o=Object.getOwnPropertyNames(t.CanvasRenderingContext2D.prototype);for(let a of o)try{if(typeof t.CanvasRenderingContext2D.prototype[a]!="function")continue;let c=ae(t.CanvasRenderingContext2D.prototype,a,function(i){return function(...p){return G(this.canvas,r,n,!0)||setTimeout(()=>{let u=mr(p,t,this);e(this.canvas,{type:me["2D"],property:a,args:u});},0),i.apply(this,p)}});s.push(c);}catch(c){let i=$e(t.CanvasRenderingContext2D.prototype,a,{set(p){e(this.canvas,{type:me["2D"],property:a,args:[p],setter:true});}});s.push(i);}return ()=>{s.forEach(a=>a());}}function Yn(e){return e==="experimental-webgl"?"webgl":e}function Ht(e,t,r,n){let s=[];try{let o=ae(e.HTMLCanvasElement.prototype,"getContext",function(a){return function(c,...i){if(!G(this,t,r,!0)){let p=Yn(c);if("__context"in this||(this.__context=p),n&&["webgl","webgl2"].includes(p))if(i[0]&&typeof i[0]=="object"){let u=i[0];u.preserveDrawingBuffer||(u.preserveDrawingBuffer=!0);}else i.splice(0,1,{preserveDrawingBuffer:!0});}return a.apply(this,[c,...i])}});s.push(o);}catch(o){console.error("failed to patch HTMLCanvasElement.prototype.getContext");}return ()=>{s.forEach(o=>o());}}function zt(e,t,r,n,s,o){let a=[],c=Object.getOwnPropertyNames(e);for(let i of c)if(!["isContextLost","canvas","drawingBufferWidth","drawingBufferHeight"].includes(i))try{if(typeof e[i]!="function")continue;let p=ae(e,i,function(u){return function(...d){let h=u.apply(this,d);if(fr(h,o,this),"tagName"in this.canvas&&!G(this.canvas,n,s,!0)){let f=mr(d,o,this),m={type:t,property:i,args:f};r(this.canvas,m);}return h}});a.push(p);}catch(p){let u=$e(e,i,{set(d){r(this.canvas,{type:t,property:i,args:[d],setter:true});}});a.push(u);}return a}function Jn(e,t,r,n){let s=[];return typeof t.WebGLRenderingContext!="undefined"&&s.push(...zt(t.WebGLRenderingContext.prototype,me.WebGL,e,r,n,t)),typeof t.WebGL2RenderingContext!="undefined"&&s.push(...zt(t.WebGL2RenderingContext.prototype,me.WebGL2,e,r,n,t)),()=>{s.forEach(o=>o());}}function Qn(e){let t;try{if(t=$t&&(self.URL||self.webkitURL).createObjectURL($t),!t)throw "";let r=new Worker(t,{name:e==null?void 0:e.name});return r.addEventListener("error",()=>{(self.URL||self.webkitURL).revokeObjectURL(t);}),r}catch(r){return new Worker("data:text/javascript;charset=utf-8,"+encodeURIComponent(yr),{name:e==null?void 0:e.name})}finally{t&&(self.URL||self.webkitURL).revokeObjectURL(t);}}function Ie(e={}){let{emit:t,checkoutEveryNms:r,checkoutEveryNth:n,blockClass:s="rr-block",blockSelector:o=null,ignoreClass:a="rr-ignore",ignoreSelector:c=null,maskTextClass:i="rr-mask",maskTextSelector:p=null,inlineStylesheet:u=true,maskAllInputs:d,maskInputOptions:h,slimDOMOptions:f,maskInputFn:m,maskTextFn:l,hooks:b,packFn:C,sampling:w={},dataURLOptions:g={},mousemoveWait:I,recordDOM:L=true,recordCanvas:D=false,recordCrossOriginIframes:H=false,recordAfter:X=e.recordAfter==="DOMContentLoaded"?e.recordAfter:"load",userTriggeredOnInput:z=false,collectFonts:q=false,inlineImages:$=false,plugins:j,keepIframeSrcFn:E=()=>false,ignoreCSSAttributes:te=new Set([]),errorHandler:M}=e;Nn(M);let v=H?window.parent===window:true,O=false;if(!v)try{window.parent.document&&(O=!1);}catch(T){O=true;}if(v&&!t)throw new Error("emit function is required");if(!v&&!O)return ()=>{};I!==void 0&&w.mousemove===void 0&&(w.mousemove=I),Z.reset();let A=d===true?{color:true,date:true,"datetime-local":true,email:true,month:true,number:true,range:true,search:true,tel:true,text:true,time:true,url:true,week:true,textarea:true,select:true,password:true}:h!==void 0?h:{password:true},F=er(f);kn();let le,Ve=0,gt=T=>{for(let Q of j||[])Q.eventProcessor&&(T=Q.eventProcessor(T));return C&&!O&&(T=C(T)),T};W=(T,Q)=>{var P;let U=T;if(U.timestamp=ve(),(P=ie[0])!=null&&P.isFrozen()&&U.type!==x.FullSnapshot&&!(U.type===x.IncrementalSnapshot&&U.data.source===R.Mutation)&&ie.forEach(Y=>Y.unfreeze()),v)t==null||t(gt(U),Q);else if(O){let Y={type:"rrweb",event:gt(U),origin:window.location.origin,isCheckout:Q};window.parent.postMessage(Y,"*");}if(U.type===x.FullSnapshot)le=U,Ve=0;else if(U.type===x.IncrementalSnapshot){if(U.data.source===R.Mutation&&U.data.isAttachIframe)return;Ve++;let Y=n&&Ve>=n,N=r&&U.timestamp-le.timestamp>r;(Y||N)&&_e(true);}};let Re=T=>{W({type:x.IncrementalSnapshot,data:{source:R.Mutation,...T}});},yt=T=>W({type:x.IncrementalSnapshot,data:{source:R.Scroll,...T}}),bt=T=>W({type:x.IncrementalSnapshot,data:{source:R.CanvasMutation,...T}}),vr=T=>W({type:x.IncrementalSnapshot,data:{source:R.AdoptedStyleSheet,...T}}),se=new dt({mutationCb:Re,adoptedStyleSheetCb:vr}),oe=new lt({mirror:Z,mutationCb:Re,stylesheetManager:se,recordCrossOriginIframes:H,wrappedEmit:W});for(let T of j||[])T.getMirror&&T.getMirror({nodeMirror:Z,crossOriginIframeMirror:oe.crossOriginIframeMirror,crossOriginIframeStyleMirror:oe.crossOriginIframeStyleMirror});let Ge=new pt;et=new ut({recordCanvas:D,mutationCb:bt,win:window,blockClass:s,blockSelector:o,mirror:Z,sampling:w.canvas,dataURLOptions:g});let Ee=new ct({mutationCb:Re,scrollCb:yt,bypassOptions:{blockClass:s,blockSelector:o,maskTextClass:i,maskTextSelector:p,inlineStylesheet:u,maskInputOptions:A,dataURLOptions:g,maskTextFn:l,maskInputFn:m,recordCanvas:D,inlineImages:$,sampling:w,slimDOMOptions:F,iframeManager:oe,stylesheetManager:se,canvasManager:et,keepIframeSrcFn:E,processedNodeManager:Ge},mirror:Z});_e=(T=false)=>{if(!L)return;W({type:x.Meta,data:{href:window.location.href,width:nr(),height:rr()}},T),se.reset(),Ee.init(),ie.forEach(P=>P.lock());let Q=Rn(document,{mirror:Z,blockClass:s,blockSelector:o,maskTextClass:i,maskTextSelector:p,inlineStylesheet:u,maskAllInputs:A,maskTextFn:l,maskInputFn:m,slimDOM:F,dataURLOptions:g,recordCanvas:D,inlineImages:$,onSerialize:P=>{ir(P,Z)&&oe.addIframe(P),ar(P,Z)&&se.trackLinkElement(P),st(P)&&Ee.addShadowRoot(S.shadowRoot(P),document);},onIframeLoad:(P,U)=>{oe.attachIframe(P,U),Ee.observeAttachShadow(P);},onStylesheetLoad:(P,U)=>{se.attachLinkElement(P,U);},keepIframeSrcFn:E});if(!Q)return console.warn("Failed to snapshot the document");W({type:x.FullSnapshot,data:{node:Q,initialOffset:tr(window)}},T),ie.forEach(P=>P.unlock()),document.adoptedStyleSheets&&document.adoptedStyleSheets.length>0&&se.adoptStyleSheets(document.adoptedStyleSheets,Z.getId(document));};try{let T=[],Q=U=>{var Y;return k(Vn)({mutationCb:Re,mousemoveCb:(N,qe)=>W({type:x.IncrementalSnapshot,data:{source:qe,positions:N}}),mouseInteractionCb:N=>W({type:x.IncrementalSnapshot,data:{source:R.MouseInteraction,...N}}),scrollCb:yt,viewportResizeCb:N=>W({type:x.IncrementalSnapshot,data:{source:R.ViewportResize,...N}}),inputCb:N=>W({type:x.IncrementalSnapshot,data:{source:R.Input,...N}}),mediaInteractionCb:N=>W({type:x.IncrementalSnapshot,data:{source:R.MediaInteraction,...N}}),styleSheetRuleCb:N=>W({type:x.IncrementalSnapshot,data:{source:R.StyleSheetRule,...N}}),styleDeclarationCb:N=>W({type:x.IncrementalSnapshot,data:{source:R.StyleDeclaration,...N}}),canvasMutationCb:bt,fontCb:N=>W({type:x.IncrementalSnapshot,data:{source:R.Font,...N}}),selectionCb:N=>{W({type:x.IncrementalSnapshot,data:{source:R.Selection,...N}});},customElementCb:N=>{W({type:x.IncrementalSnapshot,data:{source:R.CustomElement,...N}});},blockClass:s,ignoreClass:a,ignoreSelector:c,maskTextClass:i,maskTextSelector:p,maskInputOptions:A,inlineStylesheet:u,sampling:w,recordDOM:L,recordCanvas:D,inlineImages:$,userTriggeredOnInput:z,collectFonts:q,doc:U,maskInputFn:m,maskTextFn:l,keepIframeSrcFn:E,blockSelector:o,slimDOMOptions:F,dataURLOptions:g,mirror:Z,iframeManager:oe,stylesheetManager:se,shadowDomManager:Ee,processedNodeManager:Ge,canvasManager:et,ignoreCSSAttributes:te,plugins:((Y=j==null?void 0:j.filter(N=>N.observer))==null?void 0:Y.map(N=>({observer:N.observer,options:N.options,callback:qe=>W({type:x.Plugin,data:{plugin:N.name,payload:qe}})})))||[]},b)};oe.addLoadListener(U=>{try{T.push(Q(U.contentDocument));}catch(Y){console.warn(Y);}});let P=()=>{_e(),T.push(Q(document)),ze=!0;};return ["interactive","complete"].includes(document.readyState)?P():(T.push(V("DOMContentLoaded",()=>{W({type:x.DomContentLoaded,data:{}}),X==="DOMContentLoaded"&&P();})),T.push(V("load",()=>{W({type:x.Load,data:{}}),X==="load"&&P();},window))),()=>{T.forEach(U=>{try{U();}catch(Y){String(Y).toLowerCase().includes("cross-origin")||console.warn(Y);}}),Ge.destroy(),ze=!1,Ln();}}catch(T){console.warn(T);}}var Tr,Nr,y,Tt,x,R,K,ee,me,ue,B,Nt,Lt,xe,jt,Lr,Je,Qe,ve,S,De,_t,nn,sn,on,an,un,dn,Ue,ce,Dt,hn,fn,At,rt,de,Ft,ot,Pt,it,we,k,ie,Fn,Wt,He,lt,ct,fe,Gn,ye,qn,Bt,fr,mr,gr,yr,$t,ut,dt,pt,W,_e,et,ze,Z,Sr=Mr(()=>{Tr=Object.defineProperty,Nr=(e,t,r)=>t in e?Tr(e,t,{enumerable:true,configurable:true,writable:true,value:r}):e[t]=r,y=(e,t,r)=>Nr(e,typeof t!="symbol"?t+"":t,r),x=(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[e.Asset=7]="Asset",e))(x||{}),R=(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[e.CustomElement=16]="CustomElement",e))(R||{}),K=(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))(K||{}),ee=(e=>(e[e.Mouse=0]="Mouse",e[e.Pen=1]="Pen",e[e.Touch=2]="Touch",e))(ee||{}),me=(e=>(e[e["2D"]=0]="2D",e[e.WebGL=1]="WebGL",e[e.WebGL2=2]="WebGL2",e))(me||{}),ue=(e=>(e[e.Play=0]="Play",e[e.Pause=1]="Pause",e[e.Seeked=2]="Seeked",e[e.VolumeChange=3]="VolumeChange",e[e.RateChange=4]="RateChange",e))(ue||{}),B=(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",e))(B||{}),Nt={Node:["childNodes","parentNode","parentElement","textContent","ownerDocument","firstChild","lastChild","nextSibling","previousSibling"],ShadowRoot:["host","styleSheets"],Element:["shadowRoot","querySelector","querySelectorAll"],MutationObserver:[]},Lt={Node:["contains","getRootNode"],ShadowRoot:["getSelection"],Element:[],MutationObserver:["constructor"]},xe={},jt={},Lr=()=>!!globalThis.Zone;Je={};Qe={};ve=Date.now;/[1-9][0-9]{12}/.test(Date.now().toString())||(ve=()=>new Date().getTime());S={ownerDocument:_r,childNodes:Dr,parentNode:Ar,parentElement:Fr,textContent:Pr,firstChild:Ur,lastChild:Wr,nextSibling:Br,previousSibling:Hr,contains:zr,getRootNode:$r,host:jr,styleSheets:Vr,shadowRoot:Gr,querySelector:qr,querySelectorAll:Kr,nowTimestamp:ve,mutationObserverCtor:Gt,patch:ae};De=class{constructor(){y(this,"idNodeMap",new Map),y(this,"nodeMetaMap",new WeakMap);}getId(t){var r;if(!t)return -1;let n=(r=this.getMeta(t))==null?void 0:r.id;return n!=null?n:-1}getNode(t){return this.idNodeMap.get(t)||null}getIds(){return Array.from(this.idNodeMap.keys())}getMeta(t){return this.nodeMetaMap.get(t)||null}removeNodeFromMap(t){let r=this.getId(t);this.idNodeMap.delete(r),t.childNodes&&t.childNodes.forEach(n=>this.removeNodeFromMap(n));}has(t){return this.idNodeMap.has(t)}hasNode(t){return this.nodeMetaMap.has(t)}add(t,r){let n=r.id;this.idNodeMap.set(n,t),this.nodeMetaMap.set(t,r);}replace(t,r){let n=this.getNode(t);if(n){let s=this.nodeMetaMap.get(n);s&&this.nodeMetaMap.set(r,s);}this.idNodeMap.set(t,r);}reset(){this.idNodeMap=new Map,this.nodeMetaMap=new WeakMap;}};_t="__rrweb_original__";nn=/url\((?:(')([^']*)'|(")(.*?)"|([^)]*))\)/gm,sn=/^(?:[a-z+]+:)?\/\//i,on=/^www\..*/i,an=/^(data:)([^,]*),(.*)/i;un=1,dn=new RegExp("[^a-z0-9-_:]"),Ue=-2;hn=/^[^ \t\n\r\u000c]+/,fn=/^[, \t\n\r\u000c]+/;At=new WeakMap;rt=class e{constructor(...t){y(this,"parentElement",null),y(this,"parentNode",null),y(this,"ownerDocument"),y(this,"firstChild",null),y(this,"lastChild",null),y(this,"previousSibling",null),y(this,"nextSibling",null),y(this,"ELEMENT_NODE",1),y(this,"TEXT_NODE",3),y(this,"nodeType"),y(this,"nodeName"),y(this,"RRNodeType");}get childNodes(){let t=[],r=this.firstChild;for(;r;)t.push(r),r=r.nextSibling;return t}contains(t){if(t instanceof e){if(t.ownerDocument!==this.ownerDocument)return false;if(t===this)return true}else return false;for(;t.parentNode;){if(t.parentNode===this)return true;t=t.parentNode;}return false}appendChild(t){throw new Error("RRDomException: Failed to execute 'appendChild' on 'RRNode': This RRNode type does not support this method.")}insertBefore(t,r){throw new Error("RRDomException: Failed to execute 'insertBefore' on 'RRNode': This RRNode type does not support this method.")}removeChild(t){throw new Error("RRDomException: Failed to execute 'removeChild' on 'RRNode': This RRNode type does not support this method.")}toString(){return "RRNode"}};de=`Please stop import mirror directly. Instead of that,\r
|
|
2
|
+
now you can use replayer.getMirror() to access the mirror instance of a replayer,\r
|
|
3
|
+
or you can use record.mirror to access the mirror instance during recording.`,Ft={map:{},getId(){return console.error(de),-1},getNode(){return console.error(de),null},removeNodeFromMap(){console.error(de);},has(){return console.error(de),false},reset(){console.error(de);}};typeof window!="undefined"&&window.Proxy&&window.Reflect&&(Ft=new Proxy(Ft,{get(e,t,r){return t==="map"&&console.error(de),Reflect.get(e,t,r)}}));ot=class{constructor(){y(this,"id",1),y(this,"styleIDMap",new WeakMap),y(this,"idStyleMap",new Map);}getId(t){var r;return (r=this.styleIDMap.get(t))!=null?r:-1}has(t){return this.styleIDMap.has(t)}add(t,r){if(this.has(t))return this.getId(t);let n;return r===void 0?n=this.id++:n=r,this.styleIDMap.set(t,n),this.idStyleMap.set(n,t),n}getStyle(t){return this.idStyleMap.get(t)||null}reset(){this.styleIDMap=new WeakMap,this.idStyleMap=new Map,this.id=1;}generateId(){return this.id++}};Pt=(e,t)=>`${e}@${t}`,it=class{constructor(){y(this,"frozen",false),y(this,"locked",false),y(this,"texts",[]),y(this,"attributes",[]),y(this,"attributeMap",new WeakMap),y(this,"removes",[]),y(this,"mapRemoves",[]),y(this,"movedMap",{}),y(this,"addedSet",new Set),y(this,"movedSet",new Set),y(this,"droppedSet",new Set),y(this,"removesSubTreeCache",new Set),y(this,"mutationCb"),y(this,"blockClass"),y(this,"blockSelector"),y(this,"maskTextClass"),y(this,"maskTextSelector"),y(this,"inlineStylesheet"),y(this,"maskInputOptions"),y(this,"maskTextFn"),y(this,"maskInputFn"),y(this,"keepIframeSrcFn"),y(this,"recordCanvas"),y(this,"inlineImages"),y(this,"slimDOMOptions"),y(this,"dataURLOptions"),y(this,"doc"),y(this,"mirror"),y(this,"iframeManager"),y(this,"stylesheetManager"),y(this,"shadowDomManager"),y(this,"canvasManager"),y(this,"processedNodeManager"),y(this,"unattachedDoc"),y(this,"processMutations",t=>{t.forEach(this.processMutation),this.emit();}),y(this,"emit",()=>{if(this.frozen||this.locked)return;let t=[],r=new Set;for(;this.mapRemoves.length;)this.mirror.removeNodeFromMap(this.mapRemoves.shift());for(let h of this.movedSet){let f=S.parentNode(h);this.removesSubTreeCache.has(f)&&!this.movedSet.has(f)||this.addedSet.add(h);}let n=null,s=null,o=-1,a=null,c=false,i=new Set,p=this.addedSet.values(),u=p.next();for(;this.addedSet.size;){if(n!==null&&this.addedSet.has(S.previousSibling(n)))a=n,n=S.previousSibling(n);else {for(this.addedSet.has(u.value)||(u=p.next()),n=u.value;;){if(s=S.parentNode(n),this.addedSet.has(s)){n=s;continue}break}if(i.has(s))s=null;else if(s){if(cr(s)?(c=Ut(this.droppedSet,s)||this.removesSubTreeCache.has(s),c&&Ut(this.movedSet,n)&&(c=false)):c=true,this.addedSet.has(S.lastChild(s)))n=S.lastChild(s),a=null;else for(;;){if(a=S.nextSibling(n),this.addedSet.has(a)){n=a;continue}break}if(o=be(s)?this.mirror.getId(lr(n)):this.mirror.getId(s),o===-1&&s.nodeType===Node.DOCUMENT_FRAGMENT_NODE){let l=S.host(s);o=this.mirror.getId(l);}}}if(this.addedSet.delete(n),!s||o===-1){i.add(n);continue}else if(c){this.droppedSet.add(n);continue}let h=false;if(n.nodeType===Node.TEXT_NODE){let l=s.tagName;if(l==="TEXTAREA")continue;l==="STYLE"&&r.has(o)&&(h=true);}let f=a?this.mirror.getId(a):null;for(;f===Ue;)a=a&&S.nextSibling(a),f=a&&this.mirror.getId(a);if(f===-1){console.warn("Couldn't record new node. Couldn't find mirror id for nextSibling:",a),n=null;continue}let m=he(n,{doc:this.doc,mirror:this.mirror,blockClass:this.blockClass,blockSelector:this.blockSelector,maskTextClass:this.maskTextClass,maskTextSelector:this.maskTextSelector,skipChild:true,newlyAddedElement:true,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:l=>{ir(l,this.mirror)&&this.iframeManager.addIframe(l),ar(l,this.mirror)&&this.stylesheetManager.trackLinkElement(l),st(n)&&this.shadowDomManager.addShadowRoot(S.shadowRoot(n),this.doc);},onIframeLoad:(l,b)=>{this.iframeManager.attachIframe(l,b),this.shadowDomManager.observeAttachShadow(l);},onStylesheetLoad:(l,b)=>{this.stylesheetManager.attachLinkElement(l,b);},cssCaptured:h});m&&(t.push({parentId:o,nextId:f,node:m}),r.add(m.id));}let d={texts:this.texts.map(h=>{let f=h.node,m=S.parentNode(f);return m&&m.tagName==="TEXTAREA"&&this.genTextAreaValueMutation(m),{id:this.mirror.getId(f),value:h.value}}).filter(h=>!r.has(h.id)).filter(h=>this.mirror.has(h.id)),attributes:this.attributes.map(h=>{let{attributes:f}=h;if(typeof f.style=="string"){let m=JSON.stringify(h.styleDiff),l=JSON.stringify(h._unchangedStyles);m.length<f.style.length&&(m+l).split("var(").length===f.style.split("var(").length&&(f.style=h.styleDiff);}return {id:this.mirror.getId(h.node),attributes:f}}).filter(h=>!r.has(h.id)).filter(h=>this.mirror.has(h.id)),removes:this.removes,adds:t};!d.texts.length&&!d.attributes.length&&!d.removes.length&&!d.adds.length||(this.texts=[],this.attributes=[],this.attributeMap=new WeakMap,this.removes=[],this.addedSet=new Set,this.movedSet=new Set,this.droppedSet=new Set,this.removesSubTreeCache=new Set,this.movedMap={},this.mutationCb(d));}),y(this,"genTextAreaValueMutation",t=>{let r=this.attributeMap.get(t);r||(r={node:t,attributes:{},styleDiff:{},_unchangedStyles:{}},this.attributes.push(r),this.attributeMap.set(t,r));let n=Array.from(S.childNodes(t),s=>S.textContent(s)||"").join("");r.attributes.value=Ae({element:t,maskInputOptions:this.maskInputOptions,tagName:t.tagName,type:Fe(t),value:n,maskInputFn:this.maskInputFn});}),y(this,"processMutation",t=>{if(!Ze(t.target,this.mirror,this.slimDOMOptions))switch(t.type){case "characterData":{let r=S.textContent(t.target);!G(t.target,this.blockClass,this.blockSelector,false)&&r!==t.oldValue&&this.texts.push({value:Zt(t.target,this.maskTextClass,this.maskTextSelector,true)&&r?this.maskTextFn?this.maskTextFn(r,sr(t.target)):r.replace(/[\S]/g,"*"):r,node:t.target});break}case "attributes":{let r=t.target,n=ne(r.tagName),s=t.attributeName,o=t.target.getAttribute(s);if(s==="value"){let c=Fe(r);o=Ae({element:r,maskInputOptions:this.maskInputOptions,tagName:r.tagName,type:c,value:o,maskInputFn:this.maskInputFn});}if(G(t.target,this.blockClass,this.blockSelector,false)||o===t.oldValue)return;let a=this.attributeMap.get(t.target);if(n==="iframe"&&s==="src"&&!this.keepIframeSrcFn(o))if(!r.contentDocument)s="rr_src";else return;if(a||(a={node:t.target,attributes:{},styleDiff:{},_unchangedStyles:{}},this.attributes.push(a),this.attributeMap.set(t.target,a)),s==="type"&&n==="input"&&(t.oldValue||"").toLowerCase()==="password"&&r.setAttribute("data-rr-is-password","true"),!Qt(n,s))if(a.attributes[s]=Jt(this.doc,n,ne(s),o),s==="style"){if(!this.unattachedDoc)try{this.unattachedDoc=document.implementation.createHTMLDocument();}catch(i){this.unattachedDoc=this.doc;}let c=this.unattachedDoc.createElement("span");t.oldValue&&c.setAttribute("style",t.oldValue);for(let i of Array.from(r.style)){let p=r.style.getPropertyValue(i),u=r.style.getPropertyPriority(i);p!==c.style.getPropertyValue(i)||u!==c.style.getPropertyPriority(i)?u===""?a.styleDiff[i]=p:a.styleDiff[i]=[p,u]:a._unchangedStyles[i]=[p,u];}for(let i of Array.from(c.style))r.style.getPropertyValue(i)===""&&(a.styleDiff[i]=false);}else s==="open"&&r.tagName==="DIALOG"&&(r.matches("dialog:modal")?a.attributes.rr_open_mode="modal":a.attributes.rr_open_mode="non-modal");break}case "childList":{if(G(t.target,this.blockClass,this.blockSelector,true))return;if(t.target.tagName==="TEXTAREA"){this.genTextAreaValueMutation(t.target);return}t.addedNodes.forEach(r=>this.genAdds(r,t.target)),t.removedNodes.forEach(r=>{let n=this.mirror.getId(r),s=be(t.target)?this.mirror.getId(S.host(t.target)):this.mirror.getId(t.target);G(t.target,this.blockClass,this.blockSelector,false)||Ze(r,this.mirror,this.slimDOMOptions)||!En(r,this.mirror)||(this.addedSet.has(r)?(at(this.addedSet,r),this.droppedSet.add(r)):this.addedSet.has(t.target)&&n===-1||or(t.target,this.mirror)||(this.movedSet.has(r)&&this.movedMap[Pt(n,s)]?at(this.movedSet,r):(this.removes.push({parentId:s,id:n,isShadow:be(t.target)&&Se(t.target)?true:void 0}),Tn(r,this.removesSubTreeCache))),this.mapRemoves.push(r));});break}}}),y(this,"genAdds",(t,r)=>{if(!this.processedNodeManager.inOtherBuffer(t,this)&&!(this.addedSet.has(t)||this.movedSet.has(t))){if(this.mirror.hasNode(t)){if(Ze(t,this.mirror,this.slimDOMOptions))return;this.movedSet.add(t);let n=null;r&&this.mirror.hasNode(r)&&(n=this.mirror.getId(r)),n&&n!==-1&&(this.movedMap[Pt(this.mirror.getId(t),n)]=true);}else this.addedSet.add(t),this.droppedSet.delete(t);G(t,this.blockClass,this.blockSelector,false)||(S.childNodes(t).forEach(n=>this.genAdds(n)),st(t)&&S.childNodes(S.shadowRoot(t)).forEach(n=>{this.processedNodeManager.add(n,this),this.genAdds(n,t);}));}});}init(t){["mutationCb","blockClass","blockSelector","maskTextClass","maskTextSelector","inlineStylesheet","maskInputOptions","maskTextFn","maskInputFn","keepIframeSrcFn","recordCanvas","inlineImages","slimDOMOptions","dataURLOptions","doc","mirror","iframeManager","stylesheetManager","shadowDomManager","canvasManager","processedNodeManager"].forEach(r=>{this[r]=t[r];});}freeze(){this.frozen=true,this.canvasManager.freeze();}unfreeze(){this.frozen=false,this.canvasManager.unfreeze(),this.emit();}isFrozen(){return this.frozen}lock(){this.locked=true,this.canvasManager.lock();}unlock(){this.locked=false,this.canvasManager.unlock(),this.emit();}reset(){this.shadowDomManager.reset(),this.canvasManager.reset();}};k=e=>we?(...r)=>{try{return e(...r)}catch(n){if(we&&we(n)===true)return;throw n}}:e,ie=[];Fn=["INPUT","TEXTAREA","SELECT"],Wt=new WeakMap;He=class{constructor(t){y(this,"iframeIdToRemoteIdMap",new WeakMap),y(this,"iframeRemoteIdToIdMap",new WeakMap),this.generateIdFn=t;}getId(t,r,n,s){let o=n||this.getIdToRemoteIdMap(t),a=s||this.getRemoteIdToIdMap(t),c=o.get(r);return c||(c=this.generateIdFn(),o.set(r,c),a.set(c,r)),c}getIds(t,r){let n=this.getIdToRemoteIdMap(t),s=this.getRemoteIdToIdMap(t);return r.map(o=>this.getId(t,o,n,s))}getRemoteId(t,r,n){let s=n||this.getRemoteIdToIdMap(t);if(typeof r!="number")return r;let o=s.get(r);return o||-1}getRemoteIds(t,r){let n=this.getRemoteIdToIdMap(t);return r.map(s=>this.getRemoteId(t,s,n))}reset(t){if(!t){this.iframeIdToRemoteIdMap=new WeakMap,this.iframeRemoteIdToIdMap=new WeakMap;return}this.iframeIdToRemoteIdMap.delete(t),this.iframeRemoteIdToIdMap.delete(t);}getIdToRemoteIdMap(t){let r=this.iframeIdToRemoteIdMap.get(t);return r||(r=new Map,this.iframeIdToRemoteIdMap.set(t,r)),r}getRemoteIdToIdMap(t){let r=this.iframeRemoteIdToIdMap.get(t);return r||(r=new Map,this.iframeRemoteIdToIdMap.set(t,r)),r}},lt=class{constructor(t){y(this,"iframes",new WeakMap),y(this,"crossOriginIframeMap",new WeakMap),y(this,"crossOriginIframeMirror",new He(Yt)),y(this,"crossOriginIframeStyleMirror"),y(this,"crossOriginIframeRootIdMap",new WeakMap),y(this,"mirror"),y(this,"mutationCb"),y(this,"wrappedEmit"),y(this,"loadListener"),y(this,"stylesheetManager"),y(this,"recordCrossOriginIframes"),this.mutationCb=t.mutationCb,this.wrappedEmit=t.wrappedEmit,this.stylesheetManager=t.stylesheetManager,this.recordCrossOriginIframes=t.recordCrossOriginIframes,this.crossOriginIframeStyleMirror=new He(this.stylesheetManager.styleMirror.generateId.bind(this.stylesheetManager.styleMirror)),this.mirror=t.mirror,this.recordCrossOriginIframes&&window.addEventListener("message",this.handleMessage.bind(this));}addIframe(t){this.iframes.set(t,true),t.contentWindow&&this.crossOriginIframeMap.set(t.contentWindow,t);}addLoadListener(t){this.loadListener=t;}attachIframe(t,r){var n,s;this.mutationCb({adds:[{parentId:this.mirror.getId(t),nextId:null,node:r}],removes:[],texts:[],attributes:[],isAttachIframe:true}),this.recordCrossOriginIframes&&((n=t.contentWindow)==null||n.addEventListener("message",this.handleMessage.bind(this))),(s=this.loadListener)==null||s.call(this,t),t.contentDocument&&t.contentDocument.adoptedStyleSheets&&t.contentDocument.adoptedStyleSheets.length>0&&this.stylesheetManager.adoptStyleSheets(t.contentDocument.adoptedStyleSheets,this.mirror.getId(t.contentDocument));}handleMessage(t){let r=t;if(r.data.type!=="rrweb"||r.origin!==r.data.origin||!t.source)return;let s=this.crossOriginIframeMap.get(t.source);if(!s)return;let o=this.transformCrossOriginEvent(s,r.data.event);o&&this.wrappedEmit(o,r.data.isCheckout);}transformCrossOriginEvent(t,r){var n;switch(r.type){case x.FullSnapshot:{this.crossOriginIframeMirror.reset(t),this.crossOriginIframeStyleMirror.reset(t),this.replaceIdOnNode(r.data.node,t);let s=r.data.node.id;return this.crossOriginIframeRootIdMap.set(t,s),this.patchRootIdOnNode(r.data.node,s),{timestamp:r.timestamp,type:x.IncrementalSnapshot,data:{source:R.Mutation,adds:[{parentId:this.mirror.getId(t),nextId:null,node:r.data.node}],removes:[],texts:[],attributes:[],isAttachIframe:true}}}case x.Meta:case x.Load:case x.DomContentLoaded:return false;case x.Plugin:return r;case x.Custom:return this.replaceIds(r.data.payload,t,["id","parentId","previousId","nextId"]),r;case x.IncrementalSnapshot:switch(r.data.source){case R.Mutation:return r.data.adds.forEach(s=>{this.replaceIds(s,t,["parentId","nextId","previousId"]),this.replaceIdOnNode(s.node,t);let o=this.crossOriginIframeRootIdMap.get(t);o&&this.patchRootIdOnNode(s.node,o);}),r.data.removes.forEach(s=>{this.replaceIds(s,t,["parentId","id"]);}),r.data.attributes.forEach(s=>{this.replaceIds(s,t,["id"]);}),r.data.texts.forEach(s=>{this.replaceIds(s,t,["id"]);}),r;case R.Drag:case R.TouchMove:case R.MouseMove:return r.data.positions.forEach(s=>{this.replaceIds(s,t,["id"]);}),r;case R.ViewportResize:return false;case R.MediaInteraction:case R.MouseInteraction:case R.Scroll:case R.CanvasMutation:case R.Input:return this.replaceIds(r.data,t,["id"]),r;case R.StyleSheetRule:case R.StyleDeclaration:return this.replaceIds(r.data,t,["id"]),this.replaceStyleIds(r.data,t,["styleId"]),r;case R.Font:return r;case R.Selection:return r.data.ranges.forEach(s=>{this.replaceIds(s,t,["start","end"]);}),r;case R.AdoptedStyleSheet:return this.replaceIds(r.data,t,["id"]),this.replaceStyleIds(r.data,t,["styleIds"]),(n=r.data.styles)==null||n.forEach(s=>{this.replaceStyleIds(s,t,["styleId"]);}),r}}return false}replace(t,r,n,s){for(let o of s)!Array.isArray(r[o])&&typeof r[o]!="number"||(Array.isArray(r[o])?r[o]=t.getIds(n,r[o]):r[o]=t.getId(n,r[o]));return r}replaceIds(t,r,n){return this.replace(this.crossOriginIframeMirror,t,r,n)}replaceStyleIds(t,r,n){return this.replace(this.crossOriginIframeStyleMirror,t,r,n)}replaceIdOnNode(t,r){this.replaceIds(t,r,["id","rootId"]),"childNodes"in t&&t.childNodes.forEach(n=>{this.replaceIdOnNode(n,r);});}patchRootIdOnNode(t,r){t.type!==B.Document&&!t.rootId&&(t.rootId=r),"childNodes"in t&&t.childNodes.forEach(n=>{this.patchRootIdOnNode(n,r);});}},ct=class{constructor(t){y(this,"shadowDoms",new WeakSet),y(this,"mutationCb"),y(this,"scrollCb"),y(this,"bypassOptions"),y(this,"mirror"),y(this,"restoreHandlers",[]),this.mutationCb=t.mutationCb,this.scrollCb=t.scrollCb,this.bypassOptions=t.bypassOptions,this.mirror=t.mirror,this.init();}init(){this.reset(),this.patchAttachShadow(Element,document);}addShadowRoot(t,r){if(!Se(t)||this.shadowDoms.has(t))return;this.shadowDoms.add(t);let[n]=dr({...this.bypassOptions,doc:r,mutationCb:this.mutationCb,mirror:this.mirror,shadowDomManager:this},t);this.restoreHandlers.push(()=>n.disconnect()),this.restoreHandlers.push(pr({...this.bypassOptions,scrollCb:this.scrollCb,doc:t,mirror:this.mirror})),setTimeout(()=>{t.adoptedStyleSheets&&t.adoptedStyleSheets.length>0&&this.bypassOptions.stylesheetManager.adoptStyleSheets(t.adoptedStyleSheets,this.mirror.getId(S.host(t))),this.restoreHandlers.push(hr({mirror:this.mirror,stylesheetManager:this.bypassOptions.stylesheetManager},t));},0);}observeAttachShadow(t){!t.contentWindow||!t.contentDocument||this.patchAttachShadow(t.contentWindow.Element,t.contentDocument);}patchAttachShadow(t,r){let n=this;this.restoreHandlers.push(ae(t.prototype,"attachShadow",function(s){return function(o){let a=s.call(this,o),c=S.shadowRoot(this);return c&&cr(this)&&n.addShadowRoot(c,r),a}}));}reset(){this.restoreHandlers.forEach(t=>{try{t();}catch(r){}}),this.restoreHandlers=[],this.shadowDoms=new WeakSet;}},fe="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Gn=typeof Uint8Array=="undefined"?[]:new Uint8Array(256);for(ye=0;ye<fe.length;ye++)Gn[fe.charCodeAt(ye)]=ye;qn=function(e){var t=new Uint8Array(e),r,n=t.length,s="";for(r=0;r<n;r+=3)s+=fe[t[r]>>2],s+=fe[(t[r]&3)<<4|t[r+1]>>4],s+=fe[(t[r+1]&15)<<2|t[r+2]>>6],s+=fe[t[r+2]&63];return n%3===2?s=s.substring(0,s.length-1)+"=":n%3===1&&(s=s.substring(0,s.length-2)+"=="),s},Bt=new Map;fr=(e,t,r)=>{if(!e||!(gr(e,t)||typeof e=="object"))return;let n=e.constructor.name,s=Kn(r,n),o=s.indexOf(e);return o===-1&&(o=s.length,s.push(e)),o};mr=(e,t,r)=>e.map(n=>Le(n,t,r)),gr=(e,t)=>!!["WebGLActiveInfo","WebGLBuffer","WebGLFramebuffer","WebGLProgram","WebGLRenderbuffer","WebGLShader","WebGLShaderPrecisionFormat","WebGLTexture","WebGLUniformLocation","WebGLVertexArrayObject","WebGLVertexArrayObjectOES"].filter(s=>typeof t[s]=="function").find(s=>e instanceof t[s]);yr=`(function() {
|
|
4
|
+
"use strict";
|
|
5
|
+
var chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
|
6
|
+
var lookup = typeof Uint8Array === "undefined" ? [] : new Uint8Array(256);
|
|
7
|
+
for (var i = 0; i < chars.length; i++) {
|
|
8
|
+
lookup[chars.charCodeAt(i)] = i;
|
|
9
|
+
}
|
|
10
|
+
var encode = function(arraybuffer) {
|
|
11
|
+
var bytes = new Uint8Array(arraybuffer), i2, len = bytes.length, base64 = "";
|
|
12
|
+
for (i2 = 0; i2 < len; i2 += 3) {
|
|
13
|
+
base64 += chars[bytes[i2] >> 2];
|
|
14
|
+
base64 += chars[(bytes[i2] & 3) << 4 | bytes[i2 + 1] >> 4];
|
|
15
|
+
base64 += chars[(bytes[i2 + 1] & 15) << 2 | bytes[i2 + 2] >> 6];
|
|
16
|
+
base64 += chars[bytes[i2 + 2] & 63];
|
|
17
|
+
}
|
|
18
|
+
if (len % 3 === 2) {
|
|
19
|
+
base64 = base64.substring(0, base64.length - 1) + "=";
|
|
20
|
+
} else if (len % 3 === 1) {
|
|
21
|
+
base64 = base64.substring(0, base64.length - 2) + "==";
|
|
22
|
+
}
|
|
23
|
+
return base64;
|
|
24
|
+
};
|
|
25
|
+
const lastBlobMap = /* @__PURE__ */ new Map();
|
|
26
|
+
const transparentBlobMap = /* @__PURE__ */ new Map();
|
|
27
|
+
async function getTransparentBlobFor(width, height, dataURLOptions) {
|
|
28
|
+
const id = \`\${width}-\${height}\`;
|
|
29
|
+
if ("OffscreenCanvas" in globalThis) {
|
|
30
|
+
if (transparentBlobMap.has(id)) return transparentBlobMap.get(id);
|
|
31
|
+
const offscreen = new OffscreenCanvas(width, height);
|
|
32
|
+
offscreen.getContext("2d");
|
|
33
|
+
const blob = await offscreen.convertToBlob(dataURLOptions);
|
|
34
|
+
const arrayBuffer = await blob.arrayBuffer();
|
|
35
|
+
const base64 = encode(arrayBuffer);
|
|
36
|
+
transparentBlobMap.set(id, base64);
|
|
37
|
+
return base64;
|
|
38
|
+
} else {
|
|
39
|
+
return "";
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
const worker = self;
|
|
43
|
+
worker.onmessage = async function(e) {
|
|
44
|
+
if ("OffscreenCanvas" in globalThis) {
|
|
45
|
+
const { id, bitmap, width, height, dataURLOptions } = e.data;
|
|
46
|
+
const transparentBase64 = getTransparentBlobFor(
|
|
47
|
+
width,
|
|
48
|
+
height,
|
|
49
|
+
dataURLOptions
|
|
50
|
+
);
|
|
51
|
+
const offscreen = new OffscreenCanvas(width, height);
|
|
52
|
+
const ctx = offscreen.getContext("2d");
|
|
53
|
+
ctx.drawImage(bitmap, 0, 0);
|
|
54
|
+
bitmap.close();
|
|
55
|
+
const blob = await offscreen.convertToBlob(dataURLOptions);
|
|
56
|
+
const type = blob.type;
|
|
57
|
+
const arrayBuffer = await blob.arrayBuffer();
|
|
58
|
+
const base64 = encode(arrayBuffer);
|
|
59
|
+
if (!lastBlobMap.has(id) && await transparentBase64 === base64) {
|
|
60
|
+
lastBlobMap.set(id, base64);
|
|
61
|
+
return worker.postMessage({ id });
|
|
62
|
+
}
|
|
63
|
+
if (lastBlobMap.get(id) === base64) return worker.postMessage({ id });
|
|
64
|
+
worker.postMessage({
|
|
65
|
+
id,
|
|
66
|
+
type,
|
|
67
|
+
base64,
|
|
68
|
+
width,
|
|
69
|
+
height
|
|
70
|
+
});
|
|
71
|
+
lastBlobMap.set(id, base64);
|
|
72
|
+
} else {
|
|
73
|
+
return worker.postMessage({ id: e.data.id });
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
})();
|
|
77
|
+
//# sourceMappingURL=image-bitmap-data-url-worker-IJpC7g_b.js.map
|
|
78
|
+
`,$t=typeof self!="undefined"&&self.Blob&&new Blob([yr],{type:"text/javascript;charset=utf-8"});ut=class{constructor(t){y(this,"pendingCanvasMutations",new Map),y(this,"rafStamps",{latestId:0,invokeId:null}),y(this,"mirror"),y(this,"mutationCb"),y(this,"resetObservers"),y(this,"frozen",false),y(this,"locked",false),y(this,"processMutation",(i,p)=>{(this.rafStamps.invokeId&&this.rafStamps.latestId!==this.rafStamps.invokeId||!this.rafStamps.invokeId)&&(this.rafStamps.invokeId=this.rafStamps.latestId),this.pendingCanvasMutations.has(i)||this.pendingCanvasMutations.set(i,[]),this.pendingCanvasMutations.get(i).push(p);});let{sampling:r="all",win:n,blockClass:s,blockSelector:o,recordCanvas:a,dataURLOptions:c}=t;this.mutationCb=t.mutationCb,this.mirror=t.mirror,a&&r==="all"&&this.initCanvasMutationObserver(n,s,o),a&&typeof r=="number"&&this.initCanvasFPSObserver(r,n,s,o,{dataURLOptions:c});}reset(){this.pendingCanvasMutations.clear(),this.resetObservers&&this.resetObservers();}freeze(){this.frozen=true;}unfreeze(){this.frozen=false;}lock(){this.locked=true;}unlock(){this.locked=false;}initCanvasFPSObserver(t,r,n,s,o){let a=Ht(r,n,s,true),c=new Map,i=new Qn;i.onmessage=m=>{let{id:l}=m.data;if(c.set(l,false),!("base64"in m.data))return;let{base64:b,type:C,width:w,height:g}=m.data;this.mutationCb({id:l,type:me["2D"],commands:[{property:"clearRect",args:[0,0,w,g]},{property:"drawImage",args:[{rr_type:"ImageBitmap",args:[{rr_type:"Blob",data:[{rr_type:"ArrayBuffer",base64:b}],type:C}]},0,0]}]});};let p=1e3/t,u=0,d,h=()=>{let m=[];return r.document.querySelectorAll("canvas").forEach(l=>{G(l,n,s,true)||m.push(l);}),m},f=m=>{if(u&&m-u<p){d=requestAnimationFrame(f);return}u=m,h().forEach(async l=>{var b;let C=this.mirror.getId(l);if(c.get(C)||l.width===0||l.height===0)return;if(c.set(C,true),["webgl","webgl2"].includes(l.__context)){let g=l.getContext(l.__context);((b=g==null?void 0:g.getContextAttributes())==null?void 0:b.preserveDrawingBuffer)===false&&g.clear(g.COLOR_BUFFER_BIT);}let w=await createImageBitmap(l);i.postMessage({id:C,bitmap:w,width:l.width,height:l.height,dataURLOptions:o.dataURLOptions},[w]);}),d=requestAnimationFrame(f);};d=requestAnimationFrame(f),this.resetObservers=()=>{a(),cancelAnimationFrame(d);};}initCanvasMutationObserver(t,r,n){this.startRAFTimestamping(),this.startPendingCanvasMutationFlusher();let s=Ht(t,r,n,false),o=Xn(this.processMutation.bind(this),t,r,n),a=Jn(this.processMutation.bind(this),t,r,n);this.resetObservers=()=>{s(),o(),a();};}startPendingCanvasMutationFlusher(){requestAnimationFrame(()=>this.flushPendingCanvasMutations());}startRAFTimestamping(){let t=r=>{this.rafStamps.latestId=r,requestAnimationFrame(t);};requestAnimationFrame(t);}flushPendingCanvasMutations(){this.pendingCanvasMutations.forEach((t,r)=>{let n=this.mirror.getId(r);this.flushPendingCanvasMutationFor(r,n);}),requestAnimationFrame(()=>this.flushPendingCanvasMutations());}flushPendingCanvasMutationFor(t,r){if(this.frozen||this.locked)return;let n=this.pendingCanvasMutations.get(t);if(!n||r===-1)return;let s=n.map(a=>{let{type:c,...i}=a;return i}),{type:o}=n[0];this.mutationCb({id:r,type:o,commands:s}),this.pendingCanvasMutations.delete(t);}},dt=class{constructor(t){y(this,"trackedLinkElements",new WeakSet),y(this,"mutationCb"),y(this,"adoptedStyleSheetCb"),y(this,"styleMirror",new ot),this.mutationCb=t.mutationCb,this.adoptedStyleSheetCb=t.adoptedStyleSheetCb;}attachLinkElement(t,r){"_cssText"in r.attributes&&this.mutationCb({adds:[],removes:[],texts:[],attributes:[{id:r.id,attributes:r.attributes}]}),this.trackLinkElement(t);}trackLinkElement(t){this.trackedLinkElements.has(t)||(this.trackedLinkElements.add(t),this.trackStylesheetInLinkElement(t));}adoptStyleSheets(t,r){if(t.length===0)return;let n={id:r,styleIds:[]},s=[];for(let o of t){let a;this.styleMirror.has(o)?a=this.styleMirror.getId(o):(a=this.styleMirror.add(o),s.push({styleId:a,rules:Array.from(o.rules||CSSRule,(c,i)=>({rule:Kt(c,o.href),index:i}))})),n.styleIds.push(a);}s.length>0&&(n.styles=s),this.adoptedStyleSheetCb(n);}reset(){this.styleMirror.reset(),this.trackedLinkElements=new WeakSet;}trackStylesheetInLinkElement(t){}},pt=class{constructor(){y(this,"nodeMap",new WeakMap),y(this,"active",false);}inOtherBuffer(t,r){let n=this.nodeMap.get(t);return n&&Array.from(n).some(s=>s!==r)}add(t,r){this.active||(this.active=true,requestAnimationFrame(()=>{this.nodeMap=new WeakMap,this.active=false;})),this.nodeMap.set(t,(this.nodeMap.get(t)||new Set).add(r));}destroy(){}},ze=false;try{if(Array.from([1],e=>e*2)[0]!==2){let e=document.createElement("iframe");document.body.appendChild(e),Array.from=((Tt=e.contentWindow)==null?void 0:Tt.Array.from)||Array.from,document.body.removeChild(e);}}catch(e){console.debug("Unable to override Array.from",e);}Z=en();Ie.addCustomEvent=(e,t)=>{if(!ze)throw new Error("please add custom event after start recording");W({type:x.Custom,data:{tag:e,payload:t}});};Ie.freezePage=()=>{ie.forEach(e=>e.freeze());};Ie.takeFullSnapshot=e=>{if(!ze)throw new Error("please take full snapshot after start recording");_e(e);};Ie.mirror=Z;});var wt="[data-ck-mask]",vt="[data-ck-block]";var Ct=e=>{let t=2166136261;for(let r=0;r<e.length;r++)t^=e.charCodeAt(r),t=Math.imul(t,16777619);return (t>>>0)/4294967296};var Ke=1800*1e3,Xe=60*1e3,Mt=30*1e3,Rr=5*1e3,Ye=64*1024,Er=4*1024*1024,It=1024*1024,kr=[vt,'input[type="password"]','input[type="hidden"]','[autocomplete^="cc-"]','input[name*="card" i]','input[name*="cvc" i]','input[name*="cvv" i]','iframe[src*="js.stripe.com"]','iframe[src*="paypal.com"]'].join(","),xr=wt,Rt=(e,t)=>Ct(`replay:${e}`)<Math.min(1,Math.max(0,t)),Et=e=>{let t=e.toLowerCase().replace(/^\$/,"");return t.startsWith("purchase")?"purchase":t.startsWith("checkout")?"checkout":null},Or=e=>"*".repeat(Math.min(12,e.length)),kt=e=>({emit:e,maskAllInputs:true,maskInputOptions:{color:true,date:true,"datetime-local":true,email:true,month:true,number:true,range:true,search:true,tel:true,text:true,time:true,url:true,week:true,textarea:true,select:true,password:true},maskInputFn:Or,maskTextSelector:xr,blockSelector:kr,recordCanvas:false,recordCrossOriginIframes:false,collectFonts:false,inlineImages:false,slimDOMOptions:"all",sampling:{mousemove:50,scroll:150,media:800,input:"last"}}),ke=class{constructor(t=Xe,r=Er){ge(this,"windowMs",t);ge(this,"maxBytes",r);ge(this,"segments",[]);}push(t,r){(t.type===4||!this.segments.length)&&this.segments.push({events:[],bytes:0});let n=this.segments[this.segments.length-1];n.events.push(t),n.bytes+=r;let s=t.timestamp-this.windowMs;for(;this.segments.length>1&&(this.segments[1].events[0].timestamp<=s||this.bytes>this.maxBytes);)this.segments.shift();}get bytes(){return this.segments.reduce((t,r)=>t+r.bytes,0)}get size(){return this.segments.reduce((t,r)=>t+r.events.length,0)}get first(){var t,r,n;return (n=(r=(t=this.segments[0])==null?void 0:t.events[0])==null?void 0:r.timestamp)!=null?n:null}drain(){let t=this.segments.flatMap(r=>r.events);return this.segments=[],t}clear(){this.segments=[];}},xt=(e,t)=>e>=Ye||e>0&&t>=Rr,Ot=e=>{let t="";for(let r=0;r<e.length;r+=32768)t+=String.fromCharCode(...e.subarray(r,r+32768));return btoa(t)};var mt=(e,t)=>String(e!=null?e:"").slice(0,t),je=()=>window.location.pathname.slice(0,300)||"/",Zn=async e=>{let t=new Blob([e]).stream().pipeThrough(new CompressionStream("gzip"));return new Uint8Array(await new Response(t).arrayBuffer())},wr=async e=>{if(typeof window=="undefined")return null;let{record:t}=await Promise.resolve().then(()=>(Sr(),br)),r=`${e.host}/api/sdk/replay`,n=Rt(e.sessionId,e.sampleRate)?"upload":"buffer",s=n==="upload"?"sample":null,o=e.distinctId,a=e.identified===true,c=null,i=0,p=false,u=Date.now(),d=new ke,h=[],f=0,m=Date.now(),l=[{t:Date.now(),kind:"pageview",path:je()}],b=Promise.resolve(),C=M=>{p||(!M&&n==="upload"&&g(false),p=true,j==null||j(),window.clearInterval(E),window.clearInterval(te),window.removeEventListener("error",X),window.removeEventListener("unhandledrejection",z),window.removeEventListener("pagehide",q),document.removeEventListener("visibilitychange",$),console.error===H&&(console.error=D),h=[],d.clear(),l=[]);},w=async(M,v,O)=>{let A;if(!O&&typeof CompressionStream!="undefined"?A=JSON.stringify({...M,enc:"gzip",data:Ot(await Zn(v))}):A=JSON.stringify({...M,enc:"json",data:v}),A.length>It){e.warn("A recording chunk was over 1 MB (a very large page). The recording stopped."),C(true);return}if(!(O&&"sendBeacon"in navigator&&navigator.sendBeacon(r,A)))try{let F=await fetch(r,{method:"POST",headers:{"content-type":"application/json"},body:A,keepalive:O||A.length<6e4});(F.status===403||F.status===409||F.status===413)&&C(!0);}catch(F){e.warn(`Could not reach ${e.host||"this origin"} to upload a recording.`);}};function g(M){if(!h.length)return;let v=h;h=[],f=0,m=Date.now(),c!=null||(c=v[0].timestamp);let O=l;l=[];let A={key:e.apiKey,sessionId:e.sessionId,distinctId:o,identified:a,start:c,seq:i++,consent:{replay:true},trigger:s,final:M,meta:{first:v[0].timestamp,last:v[v.length-1].timestamp,vw:window.innerWidth,vh:window.innerHeight,marks:O}},F=`[${v.map(le=>le.json).join(",")}]`;M?w(A,F,true):b=b.then(()=>w(A,F,false));}let I=M=>{p||n==="upload"||(n="upload",s=M,window.clearInterval(te),h=d.drain(),f=h.reduce((v,O)=>v+O.json.length,0),g(false));},L=M=>{var A;if(p)return;if(Date.now()-(c!=null?c:u)>Ke){C(false);return}let v=JSON.stringify(M),O={type:M.type,timestamp:M.timestamp,json:v};if(n==="buffer"){d.push(O,v.length);let F=(A=d.first)!=null?A:M.timestamp-Xe;l=l.filter(le=>le.t>=F);return}h.push(O),f+=v.length,f>=Ye&&g(false);},D=console.error,H=(...M)=>{try{t.addCustomEvent("$console",{level:"error",text:mt(M.map(v=>v instanceof Error?v.message:typeof v=="string"?v:"[object]").join(" "),300)});}catch(v){}D.apply(console,M);},X=M=>{let v=mt(M.message||"Script error",200);l.push({t:Date.now(),kind:"error",path:je(),label:v});try{t.addCustomEvent("$error",{message:v});}catch(O){}I("error");},z=M=>{let v=M.reason,O=mt(typeof(v==null?void 0:v.message)=="string"?v.message:"Unhandled promise rejection",200);l.push({t:Date.now(),kind:"error",path:je(),label:O});try{t.addCustomEvent("$error",{message:O});}catch(A){}I("error");},q=()=>n==="upload"&&g(true),$=()=>document.visibilityState==="hidden"&&n==="upload"&&g(false),j=t(kt(L));if(!j)return null;console.error=H,window.addEventListener("error",X),window.addEventListener("unhandledrejection",z),window.addEventListener("pagehide",q),document.addEventListener("visibilitychange",$);let E=window.setInterval(()=>{Date.now()-(c!=null?c:u)>Ke?C(false):n==="upload"&&xt(f,Date.now()-m)&&g(false);},1e3),te=n==="buffer"?window.setInterval(()=>t.takeFullSnapshot(true),Mt):0;return {event:M=>{let v=Et(M);v&&I(v);},click:(M,v)=>{if(p)return;let O=Date.now(),A=je(),F=M.label||M.selector.split(" > ").pop()||"";l.push({t:O,kind:"click",path:A,label:F,x:M.x,y:M.y,vw:M.vw,dead:!M.interactive}),v&&(l.push({t:O,kind:"rage",path:A,label:F,x:M.x,y:M.y,vw:M.vw}),I("rage"));},page:M=>!p&&l.push({t:Date.now(),kind:"pageview",path:M.slice(0,300)||"/"}),identify:M=>{o=M,a=true;},stop:(M=false)=>C(M)}};window.__mrrocketReplay={startReplay:wr};})();
|